Recovering an SVN repository

Subversion
Jan
30

It is inevitable that at some point you're going to run into problems with SVN, whether it be from upgrading it to a newer version that runs a later version of the Berkeley database or if you move your repository. Here we look at how you can recover from this.

First time I ever upgraded SVN I regretted it soon after - my repository stopped working and it seemed that I wasn't able to recover it. Since I'd reinstalled Windows and moved my repository location as a result (and was now using a newer version of SVN too) I wasn't sure what to do at first. Then I discovered this the proper method to recover from this situation. First, use the following command:

svnadmin recover <repos-location>

You will need to replace repos-location with the path to your repository, but this is the first stage to take as it will bring the repository "back into a consistent state". It doesn't stop there though, next you need to use:

svnadmin list-unused-dblogs <repos-location>

Again, you need to replace repos-location with the path to your repository. The purpose of this is so that we can remove Berkeley log files and tell it everything is okay with the repository now. Before we can do that though we need to know which log files are safe to be deleted - and that is what the above command does. This will then list multiple files such as db/log.00000004 - all of these in this format can be removed. One way to automatically remove these files is to use:

svnadmin list-unused-dblogs <repos-location> | xargs rm

That's it! You've fixed your SVN repository.

your comments - Post a comment

blog comments powered by Disqus