Bash Script: Incremental Encrypted Backups with Duplicity (Amazon S3)
Update (5/6/12): I have not been actively developing this script lately. Zertrin has stepped up to take over the reins and offers a up-to-date and modified version with even more capabilities. Check it out over at github.
This bash script was designed to automate and simplify the remote backup process of duplicity on Amazon S3. After your script is configured, you can easily backup, restore, verify and clean (either via cron or manually) your data without having to remember lots of different command options and passphrases.
Most importantly, you can easily backup the script and your gpg key in a convenient passphrase-encrypted file. This comes in in handy if/when your machine ever does go belly up. Code is hosted at github.
how to use
To get the latest latest code in the script you can download a zip copy of the source or clone the git repository like so:
git clone git://github.com/thornomad/dt-s3-backup.git
You’ll also need to have a number of things in place in order to utilize this script, specifically: gpg, duplicity, an Amazon S3 account, and (optionally) s3cmd. If you need help getting all these in order, I wrote another post about putting it all together. It’s not all that difficult, but does take a few pieces of the puzzle to be in order.
Once you have the script, you will need to fill out the foobar variables with your own specific information. I suggest testing the script on a small directory of files and a local directory for your destination first to make sure it is working.
From the README file:
COMMON USAGE EXAMPLES ===================== * View help: $ dt-s3-backup.sh * Run an incremental backup: $ dt-s3-backup.sh --backup * Force a one-off full backup: $ dt-s3-backup.sh --full * Restore your entire backup: $ dt-s3-backup.sh --restore You will be prompted for a restore directory $ dt-s3-backup.sh --restore /home/user/restore-folder You can also provide a restore folder on the command line. * Restore a specific file in the backup: $ dt-s3-backup.sh --restore-file You will be prompted for a file to restore to the current directory $ dt-s3-backup.sh --restore-file img/mom.jpg Restores the file img/mom.jpg to the current directory $ dt-s3-backup.sh --restore-file img/mom.jpg /home/user/i-love-mom.jpg Restores the file img/mom.jpg to /home/user/i-love-mom.jpg * List files in the remote archive $ dt-s3-backup.sh --list-current-files * Verify the backup $ dt-s3-backup.sh --verify * Backup the script and gpg key (for safekeeping) $ dt-s3-backup.sh --backup-script
You can view the changelog at github.