Backup to USB Drive
Introduction
For same applications it might be necessary to use an external drive without adding this drive to a ZPool. E.g. if you want to copy from or to an external device.
Setup / mounting
TrueNAS will not mount a drive automatically when plugged into an USB Port. This has to be done manually. In this example I will use an external drive from LaCie.
- Plug in the drive to any USB Port
- Figure out the name of the device. It can be seen in Storage --> Disks. It is usually the drive without pool.
- Enter
It will show show the exact name of the partition you want to mount.lsblk -p | grep "disk\|part"
In this case it is sdd2. - Enter
blkid /dev/sdd2
It will show you the UUID of the partition you want to mount
root@nas04[/home/admin]# blkid /dev/sdd2 /dev/sdd2: LABEL_FATBOOT="EFI" LABEL="EFI" UUID="B7D1-A689" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="5545caa6-b0c3-4558-b222-aac5fb9c0026"
- Create a mountpoint
mkdir /mnt/LaCie
- add to fstab
UUID=B7D1-A689 /mnt/LaCie vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 0
- Mount the device
mount -a
Explanation
It seems to be awkward to make so many steps to mount an USB device. However, TrueNAS does no auto mount. So a permanent mount must be added manually to the fstab. And furthermore, TrueNAS seems to change the name of the partition frequently, so the UUID of the partition has to be used.
Create an rsync job
Create the file /root/rsync_exclude.txt with this content:
ix-applications
replika
.~tmp~
*/._*
*/.DocumentRevisions-V100/
*/.DS_Store
*/.fseventsd/
*/.Spotlight-V100/
*/.TemporaryItems/
*/.Trashes/
.@*
.*
@Recycle
*.@__thumb
sync.ffs_lock
All these files/directories will not be copied to the target drive. These items are created by MacOS and will automaticall re-created, when these objects in the backup are used by MacOS.
The command for the rsync job looks like this:
rsync -av --delete --log-file="/var/log/rsyncd.LaCie.log" --no-perms --no-owner --exclude-from "/root/rsync_exclude.txt" /mnt/N4pool/ /mnt/LaCie/backup
If you want to run it over the network:
rsync -av --delete --log-file="/var/log/rsyncd.LaCie.log" --no-perms --no-owner --exclude-from "/root/rsync_exclude.txt" rsync@nas04.simmy.ch:/mnt/N4pool/ /mnt/LaCie/backup
Add to cron
Goto System settings --> Advanced -->Cron Jobs Add
Useful links
Manually mount a USB drive in the Linux terminal