SVN Repository Corruption – svn/db/current: End of file found

Version control systems such as subversion (short SVN) are great backup tools. But what if the SVN respository itself gets corrupted and no backup of the backup is available? This post demonstrates
how to recover from certain SVN repository corruptions.

For me, problems started when a svn commit aborted with the error message

PATH_TO_REPO/svn/db/current: End of file found

Examination of the file PATH_TO_REPO/svn/db/current revealed, that it was of zero size, vulgo empty. Looking out for solutions, I came across this post on the subversion user mailing list that describes how to restore this file.

First, navigate to the sub-directories of PATH_TO_REPO/svn/db/revs to learn about the youngest revision number of your subversion repository, e.g. the number of the latest revision. Each revision has a file entry in this path, named with the revision number. So the highest filename yields the youngest revision number.

Next, edit the file PATH_TO_REPO/svn/db/current by adding a single line

<youngest revision> zzzzz zzzzz

So for example if your youngest revision number was 5432, then the file should read

5432 zzzzz zzzzz

afterwards (the second and third colum are dummy entries).

Providing a transitional PATH_TO_REPO/svn/db/current enables us now to dump the entire SVN repository including all the information about revisions etc. into a backup file

svnadmin dump PATH_TO_REPO > svn.dump

If repository corruption affected only PATH_TO_REPO/svn/db/current, this step will succeed. However, if you are unlucky, you will encounter

* Dumped revision 5431.
svnadmin: Malformed file

or similar error messages. There might be plenty of reasons for this. This post here has some work-around, which ran me straight into another error

svnadmin: Can't set position pointer in file 'PATH_TO_REPO/svn/db/revs/0/5431': Invalid argument

It is important to recognize that the line just before svnadmin: Malformed file gives you the last revision that was dumped successfully. In my case, this meant that only the last revision was corrupted and I simply skipped that revision. Similarly, you might also skip corrupted revisions, see the -r argument of the svnadmin dump command,

svnadmin dump -r 0:5431 PATH_TO_REPO > svn_repo.dump

After having created a backup of the SVN repository successfully, move the old repository into some safe part,

mv PATH_TO_REPO /backup

and then create a new SVN repository at the original location

svnadmin create PATH_TO_REPO

Finally, load the backup into the repository (given that the repository was empty, as in our case, it will even have the same UUID afterwards).

svnadmin load PATH_TO_REPO < svn_repo.dump

Having arrived here, you will be able to use your SVN repository just as before.

4 thoughts on “SVN Repository Corruption – svn/db/current: End of file found

  1. mike

    You’ve saved my bacon here my friend! I had a repo with 8 months work in that just flipped out with “end of file” error (due to server running out of space i think) … but I’m nack up and running now 🙂 Cheers

    Reply
  2. wilson

    Thanks a lot. Got back the data from a corrupted repository.
    As Sayali mentioned add a new line in the “Current” file

    Reply

Leave a reply to mike Cancel reply