Saturday, 24 December 2011

Backing up to Amazon S3 from Ubuntu 11.10

These are the steps to setup a periodic backup directories on an Ubuntu 11.10 server to the Amazon S3 service:

WARNING: Some irony here, but make sure you backup your data before attempting this, there *shouldn't* be much risk, but I won't be responsible if you loose any data or incur any financial loss from following any of this.

1. Create Amazon S3 account & storage bucket
  1. Check you projected costs are acceptable here.
  2. Register with Amazon S3.
  3. Go to the Amazon S3 console and create a bucket for your backup.

2. Install the necessary software packages on Ubuntu
Run the following to install the packages:
apt-get install backup-manager libnet-amazon-s3-perl

3. Configure backup-manager
You configure backup manager by editing the /etc/backup-manager.conf configuration file. There are settings I have modified from the default, I haven't given the values for all of the config parameters as I recommend you think about these and use your own:
  • export BM_ARCHIVE_TTL="..." 
  • export BM_ARCHIVE_METHOD="tarball-incremental" - Note, this is recommended to reduce the amount of data transferred and stored on the S3 servers.
  • export BM_TARBALL_DIRECTORIES="..." - space separated list of the directories you would like to backup.
  • export BM_UPLOAD_METHOD="s3"
Amazon S3 specific parameters of the config file, you will get the access and secret keys from the Security Credentials section of the Amazon S3 website:
  • export BM_UPLOAD_S3_DESTINATION="your_bucket_name"
  • export BM_UPLOAD_S3_ACCESS_KEY="..."
  • export BM_UPLOAD_S3_SECRET_KEY="..."
  • export BM_UPLOAD_S3_PURGE="false"

4. Test your settings
You can test your settings by running a manual backup (this will cost money, as you will be uploading to the Amazon S3 server):
backup-manager -v 
You can verify you backups were uploaded by looking at your Amazon S3 console.

5. Add the backup task to CRON
I decided to have my incremental backups run daily. So created a backup-manager script in /etc/cron.daily/backup_manager, containing with the following:
/usr/sbin/backup-manager -v
Don't forget to make the script executable.

That's it, you should now have your backups setup and backing up to the bucket you created on the Amazon S3 service.

I take no responsibility what-so-ever for any loss of data or financial costs incurred by someone following the info in this blog! Remember, each time you backup to the S3 service, it will cost you a certain amount of money.


  1. Thanks a lot for the article - very straight.

    Found you miss to mention this key:
    export BM_UPLOAD_METHOD="s3"


    Carlos Ruiz

  2. Hi Carlos,
    Thank you for spotting that!