Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Repair corrupted SVN repository

I am using svnX (0.9.13) on Mac OS X Lion (10.7.2 11C74) and have seem to have, what I believe, is a corrupted SVN repository. I have searched the site for similar questions and have found a couple, yet none describe how to recover when you cannot complete a checkout from the repository. I do not have an up to date working directory either.

The specific error is:

svn: Checksum mismatch while reading representation:
expected: [hash]
actual: [different hash]

If the alert is dismissed (the only option), the checkout will continue until the end. On first glance, most of the files seem to be there, but when I run the application, it is clear there is a mishmash of versions. The repository lives on a USB flash drive, which could be a source of corruption. I am the only user who access these files and they have not been touched for over a week and were in a working state.

Any suggestions on how to proceed would be appreciated.

like image 537
Noren Avatar asked Jan 12 '12 20:01

Noren


1 Answers

When you have a corrupt repository, your only real chance in saving the information is to do a dump and load. If you're lucky, doing a dump and load will sometimes correct the corruption.

If not, you can use the -r <from>:<to> parameter on the dump to skip over the bad revisions. You can create several dump files and merge them into a single repository, so you can skip over the bad revision numbers. I've noticed that each dump file starts with a complete revision of the repository at that revision, and the dump/load process is usually smart enough not to double up changes.

In fact, I believe you can even put several dumps into a single dump file without too many problems. The following should skip over revisions 1001 and 1204 which are bad revisions:

$ svnadmin dump -r1:1000 my_repos > dumpfile.txt
$ svnadmin dump --incremental -r1002:1203 my_repos >> dumpfile.txt
$ svnadmin dump --incremental -r1205:HEAD my_repos >> dumpfile.txt
$ svnadmin load my_repos2 < dumpfile.txt

There are several Subversion backup scripts that backup the repository by taking dumps of the newest revisions. For example, the first time you run it, it dumps everything from the first revision to the last version (say revision 1000). Then, the next day it dumps revision 1001 to the last revision (say 1003), and the next day, revision 1004 to the last revision.

To restore, you have to restore all the dumps, but the backup times are suppose to be shorter than doing a full dump each time.

You can also do a hotcopy, but I don't find doing a hotcopy that much faster than doing a dump, and there could be issues if you have to move your repository to a different machine.

like image 93
David W. Avatar answered Sep 23 '22 08:09

David W.