You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1.0 KiB
30 lines
1.0 KiB
7 years ago
|
#!/usr/bin/bash
|
||
|
|
||
|
#Directory on the server to backup to
|
||
|
BACKUPDIR='/mnt/TimeMachine/Backup-JH/backups/'
|
||
7 years ago
|
LATEST=$(ssh officeServerJH ls ${BACKUPDIR} | sort | tail -n 1)
|
||
7 years ago
|
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\
|
||
7 years ago
|
--link-dest=${BACKUPDIR}${LATEST}\
|
||
7 years ago
|
~/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\
|
||
7 years ago
|
--link-dest=${BACKUPDIR}${LATEST}\
|
||
7 years ago
|
~/Documents officeServerJH:/mnt/TimeMachine/Backup-JH/backups/${TODAY}/ --verbose
|
||
7 years ago
|
|
||
|
#At some point, add ability to delete old backups
|