如何修复一个版本损坏的存储库?
我的家庭服务器出现硬盘故障。
当我意识到磁盘正在运行时,我登录并直接复制了我的存储库,其中包含多个项目。
但是,由于磁盘出现故障,其中一项修订已损坏:
$ svnadmin verify master/
[...]
* Verified revision 820.
* Verified revision 821.
* Verified revision 822.
svnadmin: No such revision 823
master/db/revs/
和 master/db/revprops/
目录确实不包含任何名为 823
的文件,因此此修订版丢失(已损坏)。 master/
存储库中还有后续修订版(我真的很想保留!),直到修订版 #947。
今天,我获取了最新的异地备份(!),其中很高兴包含此修订版。我想通过修复丢失的版本来“修复”master/ 中损坏的存储库,因为它比备份更新。
我确保将转储文件加载到新创建的存储库中,其版本与 master/
中复制的版本相同,因此都是旧的“线性”格式 3。
我尝试了显而易见的方法,只是从备份的 db/revs/
和 db/revprops/
目录复制文件 823
:
$ cp repos/db/revs/0/823 master/db/revs/
$ cp repos/db/revprops/0/823 master/db/revprops/
目录 repos/
包含已从备份转储加载的存储库。现在我明白了:
$ svnadmin verify master/
[...]
* Verified revision 821.
* Verified revision 822.
svnadmin: /build/buildd/subversion-1.6.12dfsg/subversion/libsvn_delta/compose_delta.c:165: search_offset_index: Assertion `offset < ndx->offs[ndx->length]' failed.
Aborted
这不是很令人鼓舞。我尝试过各种其他 svnadmin 命令,但没有一个让验证者满意。
我的下一个想法是取消复制并从损坏的存储库的“新鲜”副本开始,然后转储 823 之后的修订版本,并与备份合并。但这似乎不可能,我无法在丢失的版本之后转储修订版本:
$ svnadmin dump -r 824 master/ >r824.dmp
svnadmin: No such revision 823
请注意,它无助于使转储“增量”,希望它应该假装世界从修订版本 824 开始,然后继续从那里:
$ svnadmin dump --incremental -r 824:947 master/ > dump.txt
svnadmin: No such revision 823
这确实将输出写入 dump.txt
,但我不确定它是否可靠。请注意,它不会记录已成功转储任何修订版本。
更新:我有另一个想法:将较新的修订版文件从 master/
中的 crashing-disk-copy 复制到备份中,以提供“缺失的尾部”:
$ for a in $(seq 910 947) ; do cp master/db/revs/$a repos/db/revs ; cp master/db/revprops/$a repos/db/revprops/ ; echo $a ; done
但是,这似乎除了破坏目标存储库之外什么也没做:
$ svnadmin verify repos/
[...]
* Verified revision 907.
* Verified revision 908.
* Verified revision 909.
svnadmin: Corrupt representation '907 21815 45 30922 158d3e72732f45bf6f02919b22fc899a'
svnadmin: Malformed representation header
现在,我已经没有想法了。
My home server had a hard drive failure.
Once I realized the disk was going, I logged in and did a straight copy of my repository, which contains multiple projects.
However, since the disk was failing, one of the revisions is broken:
$ svnadmin verify master/
[...]
* Verified revision 820.
* Verified revision 821.
* Verified revision 822.
svnadmin: No such revision 823
The master/db/revs/
and master/db/revprops/
directories do, indeed, not contain any files called 823
, so this revision is missing (broken). There are subsequent revisions (that I really want to keep!) in the master/
repository going up to revision #947.
Today I fetched my most recent off-site backup (!), which happily includes this revision. I would like to "heal" the broken repository in master/
by fixing the missing revision, since it is more recent than the backup.
I made sure to load the dump file into a newly created repository with the same version as the copied one in master/
, so it's all the old "linear" format 3.
I tried the obvious, to just copy the file 823
from the backup's db/revs/
and db/revprops/
directories:
$ cp repos/db/revs/0/823 master/db/revs/
$ cp repos/db/revprops/0/823 master/db/revprops/
The directory repos/
contains a repository that has been loaded from the backup dump. Now I get:
$ svnadmin verify master/
[...]
* Verified revision 821.
* Verified revision 822.
svnadmin: /build/buildd/subversion-1.6.12dfsg/subversion/libsvn_delta/compose_delta.c:165: search_offset_index: Assertion `offset < ndx->offs[ndx->length]' failed.
Aborted
Which is not very encouraging. I've tried various other svnadmin
commands, but none have made the verifier happy.
My next idea was to back out the copying and start with a "fresh" copy of the broken repository, then dump out the revisions after 823, and merge with the backup. But that doesn't seem possible, I can't dump revisions after the missing one:
$ svnadmin dump -r 824 master/ >r824.dmp
svnadmin: No such revision 823
Note that it doesn't help to make the dump "incremental", in the hopes that it should pretend the world started with revision 824 and just go from there:
$ svnadmin dump --incremental -r 824:947 master/ > dump.txt
svnadmin: No such revision 823
This does write output to dump.txt
, but I'm not sure if it can be relied upon. Note that it doesn't log that it successfully dumped any revision.
Update: I had another idea: to copy the newer revision files from the crashing-disk-copy in master/
into the backup, to provide the "missing tail":
$ for a in $(seq 910 947) ; do cp master/db/revs/$a repos/db/revs ; cp master/db/revprops/$a repos/db/revprops/ ; echo $a ; done
However, this seems to do nothing but corrupt the target repository:
$ svnadmin verify repos/
[...]
* Verified revision 907.
* Verified revision 908.
* Verified revision 909.
svnadmin: Corrupt representation '907 21815 45 30922 158d3e72732f45bf6f02919b22fc899a'
svnadmin: Malformed representation header
Now, I've run out of ideas.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我解决了。
一旦我意识到,解决方案(当然)是显而易见的。
我有这样的:
master/
:损坏的存储库的副本,具有修订版 0..947,修订版 823 的文件物理丢失。repos/
:从备份(转储文件)加载的存储库,涵盖修订版 0..910。解决方案只是从版本 911 及更高版本的
master/
转储。这是可能的,没有任何错误,我认为这意味着 911..947 范围内的任何修订都没有直接依赖于修订 823 中的状态,或者其他什么:无论如何,然后只需将转储应用到来自备份的存储库:
现在我已经恢复了完整的历史记录,没有问题:
耶!
I solved it.
The solution was (of course) obvious, once I realized it.
I had this:
master/
: A copy of a broken repository, featuring revision 0..947, with revision 823's files physically missing.repos/
: A repository loaded from a backup (dump file), covering revision 0..910.The solution was simply to dump from
master/
, from revision 911 and onwards. This was possible without any errors, which I take it means that none of the revisions in the range 911..947 directly depended on the state in revision 823, or something:Anyway, then just apply the dump to the repository coming from the backup:
And now I have the full history restored, no problems:
Yay!