Raspberry Pi. Backup to an external device

I currently have my FreePBX to backup to a local FTP server without any issues. I can’t seem to get it to backup to any external USB drive.

Is there a specific path that I need to add in?. Is there a simple way via the command line to find it please?

What can you tell us about the knowledge you have of how the usb drive is formatted and where it is currently mounted or if it is not yet mounted, these should help:-

cat /proc/partitions
blkid
mount
cat /etc/mtab
cat /etc/fstab

Thankyou for the reply. I have followed your advice and the results are listed below.

root@raspbx:~# cat /proc/partitions
major minor #blocks name

1 0 4096 ram0
1 1 4096 ram1
1 2 4096 ram2
1 3 4096 ram3
1 4 4096 ram4
1 5 4096 ram5
1 6 4096 ram6
1 7 4096 ram7
1 8 4096 ram8
1 9 4096 ram9
1 10 4096 ram10
1 11 4096 ram11
1 12 4096 ram12
1 13 4096 ram13
1 14 4096 ram14
1 15 4096 ram15
179 0 7879680 mmcblk0
179 1 262145 mmcblk0p1
179 2 7613439 mmcblk0p2
254 0 52224 zram0
254 1 52224 zram1
254 2 52224 zram2
254 3 52224 zram3
8 0 15015936 sda
8 1 15015920 sda1
root@raspbx:~# blkid
/dev/mmcblk0: PTUUID=“35786a18” PTTYPE=“dos”
/dev/mmcblk0p1: LABEL_FATBOOT=“boot” LABEL=“boot” UUID=“F661-303B” TYPE=“vfat” PARTUUID=“35786a18-01”
/dev/mmcblk0p2: LABEL=“rootfs” UUID=“8d008fde-f12a-47f7-8519-197ea707d3d4” TYPE=“ext4” PARTUUID=“35786a18-02”
/dev/zram0: UUID=“555152b8-c3f1-4cf1-9c06-4a77fac5a180” TYPE=“swap”
/dev/zram1: UUID=“f115c129-8b62-46f5-82e6-56ebb0478ffd” TYPE=“swap”
/dev/zram2: UUID=“7f88d3ca-4ec1-4fe1-a484-78843b568f5e” TYPE=“swap”
/dev/zram3: UUID=“49f18797-642c-4d6d-8a4b-6934b40a7ff6” TYPE=“swap”
/dev/sda1: UUID=“A19B-300C” TYPE=“vfat”
root@raspbx:~# mount
/dev/mmcblk0p2 on / type ext4 (rw,noatime)
devtmpfs on /dev type devtmpfs (rw,relatime,size=439400k,nr_inodes=109850,mode=755)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,relatime)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup2 on /sys/fs/cgroup/unified type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,name=systemd)
none on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,relatime,mode=700)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
mqueue on /dev/mqueue type mqueue (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
sunrpc on /run/rpc_pipefs type rpc_pipefs (rw,relatime)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=34,pgrp=1,timeout=0,minproto=5,maxproto=5,direct)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/mmcblk0p1 on /boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
/dev/mmcblk0p2 on /var/spool/hylafax/etc type ext4 (rw,noatime)
tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,size=94536k,mode=700)
root@raspbx:~# cat /etc/mtab
/dev/root / ext4 rw,noatime 0 0
devtmpfs /dev devtmpfs rw,relatime,size=439400k,nr_inodes=109850,mode=755 0 0
sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
proc /proc proc rw,relatime 0 0
securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /run tmpfs rw,nosuid,nodev,mode=755 0 0
tmpfs /run/lock tmpfs rw,nosuid,nodev,noexec,relatime,size=5120k 0 0
tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,mode=755 0 0
cgroup2 /sys/fs/cgroup/unified cgroup2 rw,nosuid,nodev,noexec,relatime,nsdelegate 0 0
cgroup /sys/fs/cgroup/systemd cgroup rw,nosuid,nodev,noexec,relatime,xattr,name=systemd 0 0
none /sys/fs/bpf bpf rw,nosuid,nodev,noexec,relatime,mode=700 0 0
cgroup /sys/fs/cgroup/perf_event cgroup rw,nosuid,nodev,noexec,relatime,perf_event 0 0
cgroup /sys/fs/cgroup/cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpu,cpuacct 0 0
cgroup /sys/fs/cgroup/pids cgroup rw,nosuid,nodev,noexec,relatime,pids 0 0
cgroup /sys/fs/cgroup/cpuset cgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0
cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0
cgroup /sys/fs/cgroup/net_cls,net_prio cgroup rw,nosuid,nodev,noexec,relatime,net_cls,net_prio 0 0
cgroup /sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0
cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0
mqueue /dev/mqueue mqueue rw,relatime 0 0
debugfs /sys/kernel/debug debugfs rw,relatime 0 0
sunrpc /run/rpc_pipefs rpc_pipefs rw,relatime 0 0
systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=34,pgrp=1,timeout=0,minproto=5,maxproto=5,direct 0 0
configfs /sys/kernel/config configfs rw,relatime 0 0
/dev/mmcblk0p1 /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro 0 0
/dev/root /var/spool/hylafax/etc ext4 rw,noatime 0 0
tmpfs /run/user/0 tmpfs rw,nosuid,nodev,relatime,size=94536k,mode=700 0 0
root@raspbx:~# cat /etc/fstab
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 2
/dev/mmcblk0p2 / ext4 defaults,noatime 0 1

a swapfile is not a swap partition, no line here

use dphys-swapfile swap[on|off] for that

root@raspbx:~#

Would I be correct in thinking that “sda1” refers to the USB stick that I’ve plugged in?.

You would be, you need to mount it somewhere the asterisk user has a path to.

mount /dev/sda1 /var/spool/asterisk/backup

is where backups have traditionally been stored, but you also need to make sure there is an entity in the filestore to cover that mount point. For permanence add a line in /etc/fstab

UUID=A19B-300C /var/spool/asterisk/backup   vfat auto,nofail,noatime,rw,user  0   0
1 Like

Many thanks for the quick response.

I have followed your instructions but get a permissions error

root@raspbx:~# cd /
root@raspbx:/# /etc/fstab
-bash: /etc/fstab: Permission denied
root@raspbx:/#

You’ve tried to execute a data file! Were you trying to edit it?

are you using the raspbx backup tool?

Ah, OK. I see the error now. I just need to edit the fstab file

1 Like

I will be using the FreePBX backup tool

We previously discovered the UUID and the format and chose a place to mount it

auto, is automount
nofail, is don’t hang the os if it’s not plugged in on booting
noatime, is don’t unnecessarily update access-time
rw, mount it read/write
user, allows regular users to mount and unmount

0 0 means don’t schedule a file system check ever

I’ve found a Windows program called “AOMEI Partition Assistant 10.1.0” that has allowed me to format two 8gb USB sticks to ext3.
I have put them into the Raspberry Pi and rebooted it. I have used the same commands to list out the drives.

root@raspbx:~# cat /proc/partitions
major minor #blocks name

1 0 4096 ram0
1 1 4096 ram1
1 2 4096 ram2
1 3 4096 ram3
1 4 4096 ram4
1 5 4096 ram5
1 6 4096 ram6
1 7 4096 ram7
1 8 4096 ram8
1 9 4096 ram9
1 10 4096 ram10
1 11 4096 ram11
1 12 4096 ram12
1 13 4096 ram13
1 14 4096 ram14
1 15 4096 ram15
179 0 7879680 mmcblk0
179 1 262145 mmcblk0p1
179 2 7613439 mmcblk0p2
8 0 7987200 sda
8 1 7987200 sda1
8 16 7782400 sdb
8 17 7781224 sdb1
254 0 52224 zram0
254 1 52224 zram1
254 2 52224 zram2
254 3 52224 zram3
root@raspbx:~# blkid
/dev/mmcblk0: PTUUID=“35786a18” PTTYPE=“dos”
/dev/mmcblk0p1: LABEL_FATBOOT=“boot” LABEL=“boot” UUID=“F661-303B” TYPE=“vfat” PARTUUID=“35786a18-01”
/dev/mmcblk0p2: LABEL=“rootfs” UUID=“8d008fde-f12a-47f7-8519-197ea707d3d4” TYPE=“ext4” PARTUUID=“35786a18-02”
/dev/sda1: UUID=“0f4e1e98-7016-4f4c-ab20-178aeb3c0802” SEC_TYPE=“ext2” TYPE=“ext3” PTUUID=“8e1bbfa8” PTTYPE=“dos” PARTUUID=“8e1bbfa8-01”
/dev/sdb1: UUID=“5ea58e07-56b8-ff4d-a69b-6ac70e6043a5” SEC_TYPE=“ext2” TYPE=“ext3” PARTUUID=“ea87340e-01”
/dev/zram0: UUID=“75d3c8d8-cc8d-4e13-8ca9-ba5be53639d2” TYPE=“swap”
/dev/zram1: UUID=“2bc866d9-cab8-4b6d-b7f8-c9014c6eaadb” TYPE=“swap”
/dev/zram2: UUID=“c6d19a38-4c02-42f0-8da4-288cd34dd1c0” TYPE=“swap”
/dev/zram3: UUID=“ba2a345e-3260-4f90-bf5f-54cb770b36e5” TYPE=“swap”
root@raspbx:~# mount
/dev/mmcblk0p2 on / type ext4 (rw,noatime)
devtmpfs on /dev type devtmpfs (rw,relatime,size=439400k,nr_inodes=109850,mode=755)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,relatime)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup2 on /sys/fs/cgroup/unified type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,name=systemd)
none on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,relatime,mode=700)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
sunrpc on /run/rpc_pipefs type rpc_pipefs (rw,relatime)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=34,pgrp=1,timeout=0,minproto=5,maxproto=5,direct)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/mmcblk0p1 on /boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
/dev/mmcblk0p2 on /var/spool/hylafax/etc type ext4 (rw,noatime)
tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,size=94536k,mode=700)
root@raspbx:~#

I’m guessing that sda1 and sdb1 are my two USB sticks?. The next few commands seem to work in adding in two folders.

root@raspbx:~# mkdir /mnt/usb
root@raspbx:~# mkdir /mnt/FreePBX_Backups
root@raspbx:~# mount /dev/sda /mnt/usb
root@raspbx:~# mount /dev/sda /mnt/FreePBX_Backups

it seems to run now, but fails on permissions.

I tried again with the other folder and I still get the same error.

Should I have used the format of ext4?

In the filestore area on FreePBX, I have it configured as…

I’m sure I’ve missed something out?.

Don’t mount the whole disk unless you really know what you are doing as when you tried to mount /dev/sda, just mount a previously formatted partition /dev/sda1 , this can be a bind mount to ‘replace’ a directory, or an arbitrary new mount point, but it must exist first. Then you need to set up a ‘filestore’ reference to your mounted device on it’ location in the fs if it is not on one already recognized (/var/spool/asterisk/backup)

/dev/sd[ab]* are all block devices and need to be mounted onto an existing FS inode, , /sda nor /sdb exist but if you had created them or more conventionally /mnt/sda1 and /mnt/sdb1 , formatted partition should be mountable there by root.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.