Repair corrupted SVN repository

后端 未结 2 1921
一整个雨季
一整个雨季 2021-02-06 06:26

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

2条回答
  •  闹比i
    闹比i (楼主)
    2021-02-06 07:10

    You should do a dump and load as David W. suggested. However there are some gotchas that I encountered and I would like to post a complete solution.

    Corruption typically occurs in single files on some revisions. We don't need to discard an entire revision just because some file had a checksum mismatch.

    First we will try disabling checksum calculation, by removing lines matching Text-content-md5

    svnadmin dump my_repo | sed '/^Text-content-md5/d' | svnadmin load second_repo
    

    The incremental approach enables us to fix errors and continue our progress. If an error happens during the dump and load, look for the last --- Committed revision X >>> --- message and put X+1 as starting revision as parameter -r and try again. This saves considerable time.

    svnadmin dump --incremental -r1:100000 my_repo | sed '/^Text-content-md5/d' | svnadmin load second_repo
    

    Or just load from the dumpfile:

    sed '/^Text-content-md5/d' dumpfile.txt | svnadmin load second_repo
    

    If that was not enough, and you're getting 'Premature end of content data in dumpstream' error or something similar, you should exclude that file completely from the dump by svndumpfilter:

    svnadmin dump --incremental -r1:100000 my_repo | svndumpfilter exclude myproject/lib/thirdparty-all.jar | sed '/^Text-content-md5/d' | svnadmin load second_repo
    

    The command above excludes myproject/lib/thirdparty-all.jar file from the dump.

    Extra information:

    • You could append --bypass-prop-validation to svnadmin load command. This works if the corruption is minor.
    • Fix Dump stream contains a malformed header (with no ':') error with appending
      | grep --binary-files=text -v '^* Dumped revision'
      to the pipe chain (before svnadmin load).

    Hope this post is useful to some people.

提交回复
热议问题