No warranty, use at your own risk, etc. I'm writing this from memory. If you run into trouble, let me know and I'll try to help. This script has been working for me for a while now (as in, I've used it to recover data after losing hard disks), but you can never be too paranoid when doing backups. Read this post about backups by jwz and do what he instructs. I do. I trust those hard disk backups more than my S3 ones, but I still additionally do a full backup to S3 every two months or so and an incremental backups on top of the last full every few weeks.
First, download all of these things and put them into a directory:
S3.rb- This is a Ruby library provided by Amazon for interacting with S3, slightly hacked-up to make it not keep the entirety of things that are being uploaded in memory and to add a progress callback on copies.- ruby-hmac - You'll need to install this library to use
S3.rb. You should just put the.rbfiles in the same directory as everything else. s3.rb- This is a utility script that implements some Unix-like commands on S3 (creating or removing buckets, listing the contents of buckets, copying files between the local machine and S3, etc.). Runs3.rb helpfor details.backup.rb- This is a script that creates GPG-encrypted incremental tar backups of a set of paths, optionally copying the backups to S3 when done.backup.sh- This is a shell script to invokebackup.rb. It can backup to a CD-R drive using cdrecord or do full and incremental backups to S3.
s3.rb working. In your home directory, create a file named .s3_auth containing a single line consisting of your S3 key ID, a space, and your S3 secret. After doing this, you should be able to run ./s3.rb mkbucket yourname to create a bucket and then copy files to and from the bucket (I think that S3 uses a global namespace for all users' buckets, so you might run into trouble if your bucket name isn't original enough).Now open
backup.sh in your favorite editor. You'll need to change the values of some of the variables at the top. secret_key needs to contain the signature of the GPG key that you want to use to encrypt your backups. bucket needs to contain the name of the S3 bucket that you previously created using s3.rb. You can ignore image_dir, iso_file, cd_dev, and cd_mnt if you're not going to write backups to CDs. Finally, scroll down to the line starting with ./backup.rb and make the --exclude arguments list any paths that you want to exclude from backups, and check that the list of paths at the end of the command contains everything that you want to back up. At this point, if I didn't screw up these instructions, you should be able to run ./backup.sh full to do a full backup to S3. As the file is copied, the script will print its progress onscreen. Temporary files and the index that tar uses to keep track of what's contained in full backups will go into ~/.backup.