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
lsblk -p | grep "disk\|part"
. It will show show the exact name of the partition you want to mount.
In this case it is sdd2. - Create a mountpoint
sudo mkdir /mnt/LaCie - Mount the device
sudo mount /dev/sdd2 /mnt/LaCie - add to fstab
/dev/sdd2 /mnt/LaCie hfsplus ro,relatime,umask=22,uid=0,gid=0,nls=utf8 0 0
Create an rsync job
rsyncCreate -anvthe --deletefile --log-file=/var/log/rsyncd.LaCie.log --exclude-from "/root/rsync_exclude.txt"txt /mnt/XPpool01/backup/qnap01/with /mnt/usb_drivethis --log-file=/var/log/rsyncd.nas01.log --no-perms content:
.recycle
ix-applications
.ssh
ftp-path
home
replika
._*
.@*
.~tmp~
.DS_Store
The command for the rsync job looks like this:
rsync -anv --delete --log-file=/var/log/rsyncd.LaCie.log --exclude-from "/root/rsync_exclude.txt" /mnt/N4pool /mnt/usb_drive --log-file=/var/log/rsyncd.nas01.log
--no-perms
-v
--exclude
"qnap01"
--exclude
" .~tmp~"
--no-perms
rsync -a --exclude-from='/exclude-file.txt' /src_directory/ /dst_directory/
Add to cronjob.cron
Goto System settings --> Advanced -->Cron Jobs Add
Open points
What happens after a reboot? Is the mount persistent or does it have to be added to fstab?
This should do the trick:
/dev/sdd2 /mnt/usb_drive hfsplus ro,relatime,umask=22,uid=0,gid=0,nls=utf8 0 0