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

Kids on Trains

You would imagine that the 20:52 train from Birmingham New Street to Ledbury would be a quiet train. That’s what I thought as I plonked myself down at a table seat. There was loads of room on the train. I could put my bag on the seat next to me and keep my iPod Nano on the table without fear taking up more than my fair share.

I pretty much had the carriage to myself, but then, just before the train left the station 2 adults and gaggle of ankle biter appear.

“Do you want to sit at a table?” the more shrill adult says to her progeny, standing next to my table.

“I already am”, I think to myself, “go and spread yourselves somewhere I’m not. There are at least 3 other empty tables in this carriage alone.” They all sat down next to me. I grumpily moved out of my slouching position to make room.

Within minutes, one of the kids made a grab for the shiny iPod. I moved it out of the way and put it down by my side. Then two of the kids start arguing over a book, engaging in a tug of war over the magazine I was reading propped up on my side of the table. I hear no remonstrations from the adults. Admittedly, I had my iPod turned on, so I there might have been something said, but I saw no evidence of the usual “the man will be angry if you don’t behave”.

I just don’t get it. We all have to share public transport, so why on a nearly empty train do people have to come and inflict their kids on other passengers (i.e. me). I would go as far to say it is rude. It shows a disregard for your fellow passenger. You might find your kids annoying, but at least put them somewhere they only annoy you, not others. They should invent some sort of ASBO for people like that.

Or, users of public transport should be given un-removable stickers with “A Bloody Menace” to stick on annoying kids..