Fix broken Subversion repository PDF Print E-mail
Written by Павел Алексеев aka Pahan-Hubbitus   
Friday, 15 April 2011 10:54

 

All known what backups is absolutely required. There nothing to discuss.

And they was present. But by some mistake my SVN repositories does not hit it...
But, I'll speak not about backups. So happened one of my partition became corrupted. Many files was not so important and was simply deleted, some recovered from backups... But for SVN repos backups was missed.

As you already could understand I speak about recovery crashed (corrupted) subversion repository. Standard "svnadmin verify" detect problem, but "svnadmin recovery" wasn't able recovery anything. It is very bad situation. I start search solution. Reading many articles across internet do not gave me solution. In most I see attempt recreate full repository structure. In my case I had kilobytes of zeros in revs files and understand it is not my case. Leaved single solution - recover repository with already saved data. In several repos it wasn't so hard - corrupted revisions just may be skiped and recovery procedure simple:

  1. Create new repository (svnadmin create)
  2. Make dump all correct revisions (svnadmin dump with --incremental option for all passes except 0)
  3. Look on what revision dump stops on error and make redump excluding it
  4. Step through 2-3 for all correct revisions.

On the end of process got repository with less revisions, but fully functional. When also present working copy, then it commited and nothing changes lost at all. Off course fresh recheckout needed because revision numbers changed.

All seams good while I work with not so seriously corrupted repository. But I have one with many errors too. It contains about 600 commits with many random placed corrupted revisions. But it is not main problem there too. Until now I do all work manually - save numerated dumps - then restore it. The main problem happened when I can't load one of the dump! Even if all dumped correctly is not guarantie what all will be loaded because there may be references to missed revisions! What is in addition is very annoying - "svndump load" do not work atomically and does not guaranty consistence of repository if error occurred! It I understand on practice. Further loading dumps may lead unpredictable behavior.  Single found solution in that situation - start loading from beginning (0 dump) and recreate repository. In that situation off course problematic dump piece must be redumped without problematic revision (if it was not boundary revision, then dump splits to two parts also).

On that phase I spent several hours to investigations and tries and make decision start scripting to make chance finish it work at all. Looking ahead I should say that it is not in vain, because the total run on the repository was in automatic mode, more than 12 hours in average...

As script was introduced there also was implemented saving original revision enumeration. Just missed in dumps revisions replaced by stub with property set (with text explanation what is it). Mostly for the leave legitimacy outer reference on its numbers in tracker, but also to do not force recheckout of working copy. Off course as it automated script there also was added several integrity checks and other useful stuff.

I should say again - do backups. Always. But if you were still in such a situation - feel free try this scripts. If you have some questions - also do not hesitate contact me.

At end some words about script itself:

  1. It is licensed under GPLv2+ (version 2.0 or any later on you choose), and without any guaranties! It help me recover repository (and I use it after that half year). But it is not insured from errors what may fullу destroy your data (in any case I recommend do experiments on copy)!
  2. This is not full application. There no mans, documentation, package and so on stuff.And I do not plan make it. It will be good known bash if you plan modify it. For just run it is not necessary.
  3. I run it only once to recover my repositories. So, any tests or speed optimizations wasn't made and do not planned.
  4. If you have any questions, comments or suggestions - please ask, I try answer. But still no any guaranties.
  5. And last. Do not hope for a miracle - information from skipped revisions is lost. It means you do not found it in logs, or merge/diff operations. So, if you have any chance fully recover your repository structure - try from it. I seen in net some offer about it, including professional and paid. If all that is not willing by some reasons or wasn't helps - try my script. At least it should help get you work repository in consistent state with all data what remained in corrupt repository!
Good luck!

 

Share/Save/Bookmark
Attachments:
Download this file (subversion_recovery.tar.bz2)subversion_recovery.tar.bz2[Скрипт восстановления Subversion (SVN) репозитория]5 Kb16/04/11 12:32
 

Add comment


Security code
Refresh