Opinions about designing, programming and using software

Recovering Subversion Repositories

Our server that hosts our Subversion repositories died recently.  I put up another server in its place and wanted to recover the Subversion repositories that we had.  They were backed up, of course, but I wanted to get the most recent versions if I could.  Since the server suffered from a motherboard failure, rather than a hard drive failure, I thought that my chances were good.

Unfortunately, I was able to find no information on recovery via binary files.  Most of the information assumes that you’ll be recovering from archived dumpfiles.  The Subversion book from Redbean has a section on migrating Subversion repositories, which is also useful for back-up.  It doesn’t mention binary recovery, though.

Fortunately, it turned out to be quite easy.

Step 1 – Copy the Repository Files

After mounting the old hard drive as read-only in the new server, I copied the repository files (which were in /srv/svn in my case) from the old drive to the new:

sudo cp -r -p /mnt/olddisk/srv/svn/* /srv/svn

The -r tells the copy operation to recurse through the directories, while the -p option preserves the permissions, ownership and timestamps.

Step 2 – Copy “Location” Entries from dav_svn.conf

Because our Subversion is set up for access over HTTP (to avoid problems with firewalls at remote locations), I had to make sure that /etc/apache2/mods-available/dav_svn.conf was properly configured on the new server.  First, I uncommented the “<Location /svn>” block and modified the authentication requirements.  I made sure that SVNParentPath was set to /srv/svn, since that’s where I put my repository files.

I then opened /mnt/olddisk/etc/apache2/mods-available/dav_svn.conf and copied the other “location” blocks from that to /etc/apache2/mods-available/dav_svn.conf. We have multiple repositories (one per client), so each repository requires its own entry. You could have a single entry and allow users to see what all of your repositories are, but that’s less secure.

Step 3 – Recreate Users

Finally, you have to recreate your users. We keep good records, so that was fairly easy.  Once this step was completed, we were able to access our old repositories immediately.

I hope that this post saves someone the research that I spent on trying to figure this out.

Post a Comment

Your email is kept private. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>