1

Say you have a Subversion repository where svnadmin verify /path/to/repo aborts at revision 42 due to an error (and the repository contains many more revisions).

The Subversion manuals then suggests:

[..] that means your repository has at least one corrupted revision, and you should restore the corrupted revision from a backup

Ok, fine - but how to do that exactly?

Is svnadmin load the right tool for that job? For example something like

svnadmin load -r 42 /path/to/some/old.dump

?

Will svnadmin load just overwrite the corrupted revision 42 and leave everything else alone?

Or do I have to restore that revision from a file based backup? And then, how do I identify all the sub-directories and files related to revision 42?

maxschlepzig
  • 35,645
  • 14
  • 145
  • 182
  • What is the exact error shown by the verify command? Also do you have an old backup? Lastly, what happens when you try svnadmin dump /path/to/repo > dumpfile.dump ? – triadiktyo Feb 04 '16 at 14:43
  • @triadiktyo, the error is `E200002: Can't read length line in file '/path/to/repo/maindir/revs/0/42'`. Yes, I have old backups. Currently, I don't have access, so I can't try to dump the current state, right now. – maxschlepzig Feb 04 '16 at 14:59
  • Similar question and problem: https://stackoverflow.com/questions/8841796/repair-corrupted-svn-repository – Nux Oct 03 '22 at 17:03

1 Answers1

1

I'll assume your backups are dump files. In which case, create a new repository using

svnadmin create /path/to/newrepo

Load your freshest backup into it using

svnadmin load /path/to/newrepo < backup.dump

This will fill the new repository with all the revisions included in the backup.

Now you need to transfer over the newer revisions from your current repository to the new repository. To do this you need to dump out the newer revisions from your current repository and load them into your new repository.

To make the example a bit easier to understand let's assume that your current repository is at revision 1500 and your backup only contained 1250 revisions. So you need to dump revision 1251 to 1500 from your current repository and load it into the new repository. To do this you need to run

svnadmin dump /path/to/currentrepo -r 1251:1500 --incremental > additionalrevs.dump
svnadmin load /path/to/newrepo < additionalrevs.dump

The --incremental flag is essential

Now in case your backups are file based backups containing the repository files on the server side, you may be able to get away with another trick. Make a copy of your current repository because we will be changing files in there and things can go wrong. Find file /path/to/repo/maindir/db/revs/0/42 in your backup and copy and replace it over the same file in your copy repository. Do the same replace using file /path/to/repo/maindir/db/revprops/0/42. Once you do this verify the new copy of the repository and there's a chance that the problem could be fixed.

triadiktyo
  • 479
  • 2
  • 9