Backing up a Subversion repository to Amazon’s S3

I’m currently working through the process of re-building my development server and have got to the stage of configuring the backup of my subversion repository to Amazon’s S3 storage ‘cloud’. Due to the inevitability of having to do it again in the near future I’m going to document how I keep my repository backed up, for myself, and for everyone else:

(This guide is assuming a freshly-squeezed Ubuntu 9.04 server install)

0. Obtain an AWS account if you haven’t already – making note of the Access key and Secret key, you’ll need them in step 2.

1. Install s3cmd

root@trogdor:~# sudo apt-get install s3cmd

2. Configure s3cmd and follow the onscreen instructions

root@trogdor:~# s3cmd --configure

3. Create the backup location

root@trogdor:~# mkdir /var/nightly_backup

4. Create the backup script (/var/nightly_backup/

svnadmin dump --quiet /var/svn/repos | gzip > /var/nightly_backup/svn.gz
s3cmd sync /var/nightly_backup s3://backup_bucket/nightly_backup/

5. Make the backup script executable

root@trogdor:~# chmod +x /var/nightly_backup

6. Amend /etc /crontab to run the backup at a suitable time (3am in this case)

... contents of /etc /crontab ...
0 3 * * * root /var/nightly_backup/

7. Wait until 3am, or run /var/nightly_backup/

8. Download an S3 browser such as S3 Browser (Windows) or Jets3t (Java)

9. Configure your S3 browser of choice to point to your AWS account to confim that the backup completed successfully.

10. ?

11. Profit.


Leave a Reply

Your email address will not be published. Required fields are marked *