Initial commit of local rsync backup script
This commit is contained in:
parent
860a056564
commit
043411bd88
1 changed files with 36 additions and 0 deletions
36
local_backup.sh
Executable file
36
local_backup.sh
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
#!/bin/bash
|
||||
|
||||
#Script to back up /home/tracey to external USB drive
|
||||
#http://www.bobulous.org.uk/misc/rsync-backup.html
|
||||
date=`date +%Y-%m-%d`
|
||||
mount_point='/media/tracey/Backup'
|
||||
log_file='/home/tracey/$date'
|
||||
|
||||
echo "#####"
|
||||
echo ""
|
||||
# Check whether target volume is mounted, and mount it if not.
|
||||
if ! mountpoint -q ${mount_point}/; then
|
||||
echo "Mounting the external USB drive."
|
||||
echo "Mountpoint is ${mount_point}"
|
||||
if ! mount ${mount_point}; then
|
||||
echo "An error code was returned by mount command!"
|
||||
exit 5
|
||||
else echo "Mounted successfully.";
|
||||
fi
|
||||
else echo "${mount_point} is already mounted.";
|
||||
fi
|
||||
# Target volume **must** be mounted by this point. If not, die screaming.
|
||||
if ! mountpoint -q ${mount_point}/; then
|
||||
echo "Mounting failed! Cannot run backup without backup volume!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Preparing to transfer differences in home directory to backup USB drive using rsync."
|
||||
|
||||
rsync -avzh --exclude '.cache' --exclude 'Videos' --exclude 'Nextloud' --exclude 'Downloads/isos' --exclude 'VirtualBox VMs' --exclude 'Sync' --exclude 'Downloads/torrents' --exclude '.local/share/Steam' --exclude 'Music' --progress --delete /home/tracey/Documents /media/tracey/Backup/tracey/Documents/ 2>&1 | tee /home/tracey/rsync-output.txt
|
||||
|
||||
echo ""
|
||||
echo "Backup Complete"
|
||||
echo "Log of this backup is in "
|
||||
echo ""
|
||||
echo "####"
|
||||
Loading…
Add table
Add a link
Reference in a new issue