Backing up a Subversion repository to Amazon’s S3
- December 11th, 2009
- Posted in Subversion
- Write comment
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/backup.sh)
#!/bin/bash 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/backup.sh
7. Wait until 3am, or run /var/nightly_backup/backup.sh.
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.
I always enjoy learning what other people think about Amazon Web Services and how they use them. Check out my very own tool CloudBerry Explorer that helps to
manage S3 on Windows . It is a freeware. http://s3.cloudberrylab.com/