I have a number of headless linux servers that I look after and backing up to USB drives is always a hassle.
Here is a nice simple method that I have discovered.
1.) Install the NTFS drivers . sudo apt-get install ntfs-3g
2.) Plug in each drive and get the UID with sudo blkid
. Note them down
3.) Create a mount point. sudo mkdir /mnt/usb_backup
.
4.) Create the script. nano backup_script.sh
. Text at the bottom of this post. The UIDs (eg 4E1AEA7B1AEA and 425CC88B5CC87B65) will be what you noted down before.
5.) Make the script executable chmod 755 backup_script.sh
6.) Test the script sudo ./backup_script
7.) Add a cron job sudo -e crontab
8.) Swap the drives as required. Not in the middle of a backup.
Note: Any new drive UIDS will need to be added as or statement || mount -U MYUID /mnt/usb_backup -o umask=000
#!/bin/bash
umount /mnt/usb_backup
if mount -U 4E1AEA7B1AEA /mnt/usb_backup -o umask=000 || mount -U 425CC88B5CC87B65 /mnt/usb_backup -o umask=000
then
rsync -ur /home/ /mnt/usb_backup/home/
touch /mnt/usb_backup/last_run.txt
fi
umount /mnt/usb_backup
Congratulations @jubbs! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Do not miss the last post from @steemitboard:
Vote for @Steemitboard as a witness to get one more award and increased upvotes!