Created
April 3, 2013 18:12
-
-
Save codatory/5303707 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Random sleep up to 55 minutes - so all my VPSes don't back up at the same time and I don't have to manually manage distribution in CRON | |
sleep $(($RANDOM / 10)) | |
export PASSPHRASE='SuperSecretPassphrase' | |
# Export backup location variable | |
backup_location="/home/backups/`hostname`/duplicity" | |
# Ensure backup location exists | |
ssh [email protected] "mkdir -p $backup_location" | |
echo "Beginning duplicity backups `date` \n\n" >> /var/log/duplicity.log | |
# Cleanup first (anything older than 21 days) | |
duplicity remove-older-than 14D -v9 "scp://[email protected]/$backup_location" >> /var/log/duplicity.log | |
# Now perform the backup | |
duplicity --exclude /base --exclude /bin --exclude /dev --exclude /proc --exclude /lib --exclude /opt --exclude /sbin --exclude /selinux --exclude /tmp --exclude /usr --exclude /var/cache --exclude /var/backups --exclude /var/spool --exclude /var/tmp --exclude /var/log --exclude /var/lock --exclude /var/lib --exclude /boot --exclude /init.rd.img --exclude /lost+found --exclude /mnt --exclude /media --exclude /vmlinuz --exclude /sys --full-if-older-than 7D / "scp://[email protected]/$backup_location" >> /var/log/duplicity.log | |
# Get the list of backups | |
duplicity collection-status "scp://[email protected]/$backup_location" >> /var/log/duplicity.log | |
echo "Duplicity backups completed `date`" >> /var/log/duplicity.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment