Entries Comments

Alex Mace’s Blog

Life & Web Development

Using Amazon S3 to back up multiple Subversion repositories

In work we use Subversion for version control and we are currently transitioning our backups onto Amazon S3. I was looking for a way to backup the Subversion repository to Amazon S3 when I came across Max Schöfmann’s post-commit hook script. Each time a commit is performed it dumps the changes to a file using svnadmin and then loads that file onto S3.

The script does have a limitation though. When it creates a dump it is put into the configured dump directory and uploads it into the S3 bucket with a filename that only refers to the revision numbers contained the in file. When a dump is created from another repository it will upload the resulting file to the same bucket and potentially overwrite a dump from a different repository with the same filename. One way around this would be to create multiple copies of the script with different configurations to put the backups into different buckets. This is not ideal. As our projects have a repository each, I had to modify the script to work with multiple repositories.

The script now assumes the last part of the path to a repository to be the name of that repository. It will use this to store the local dumps (if you keep them) in seperate directories and also to prefix the files that are loaded to S3 with this name so that the files do not conflict. I have also modified the restore script so you can pass it the name of the repository you want to restore and the path to restore it to. Thus one copy of the script can manage the backup of multiple repositories.

It was an interesting little project to play around with as I’ve hardly looked at any Ruby before so I’ve dipped my toe into that pond for the first time. It certainly seems easy enough to pick up and read anyway. Also, obviously big thanks go to Max for creating the original script. Full instructions for installation are on his page. Don’t forget to test the restore function – if it doesn’t work then you’ll just cause yourself problems when the worst happens!

Get the modified version here – s3-svn-backup.tar.gz

Tags: , , ,

3 Responses to “Using Amazon S3 to back up multiple Subversion repositories”

  1. alex says:

    Hey the download link on your modified script is broken and I would like to check it out
    Thanks

  2. Alex says:

    Hey Alex – seems to be working here, do you want to give it another go?

  3. Ciaran Dolan says:

    Your page is unreadable due to that photograph as a background.

    C.

Leave a Reply

(required)

(required)