Add simple rsync script for backing up to server

master
Jonathan Hodgson 7 years ago
parent 815a82f8f7
commit d0680fd10c
  1. 27
      bin/backup
  2. 2
      bin/backupExcludes

@ -0,0 +1,27 @@
#!/usr/bin/bash
#Directory on the server to backup to
BACKUPDIR='/mnt/TimeMachine/Backup-JH/backups/'
LATEST=$(ssh officeServerJH find ${BACKUPDIR} -type d -depth 1 | sort | tail -n 1)
TODAY=$(date -I -d "today")
echo ${LATEST##*\/}
echo ${TODAY}
#This can be tricked by having a folder with a date after the current date
if [[ ${LATEST##*\/} = ${TODAY} ]]; then
echo "There already seems to have been a backup today"
echo "If you want to rename the folder ${LATEST} then run again"
exit 0
fi
#Backup sites directory
rsync --archive --one-file-system --hard-links --human-readable --inplace\
--exclude-from=./backupExcludes\
--link-dest=${LATEST}\
~/Sites officeServerJH:/mnt/TimeMachine/Backup-JH/backups/${TODAY}/ --verbose
#Backup Documents Directory
rsync --archive --one-file-system --hard-links --human-readable --inplace\
--exclude-from=./backupExcludes\
--link-dest=${LATEST}\
~/Documents officeServerJH:/mnt/TimeMachine/Backup-JH/backups/${TODAY}/ --verbose

@ -0,0 +1,2 @@
.git/
node_modules/
Loading…
Cancel
Save