[Borgbackup] How to fix corrupted index or hints?

Thomas Waldmann tw at waldmann-edv.de
Thu Nov 17 17:27:09 EST 2022


> I am running now: borg check --verify-data --repair --debug --progress 
> --show-version --show-rc

That will be rather slow, but very thorough.

>>> Could that be produced by a merge of an backup repo to the original 
>>> one? At the end I did an rsync -a from the backup to the original 
>>> repo so the state should be the state of the backup + newer files of 
>>> the original repo.
>>
>> Uhoh, you can not do it like that and mix ("merge") stuff together.
>>
>> If you want to rsync a valid repo from location SRC to location DST, 
>> you need something like:
>>
>> rsync -a --delete SRC/ DST/
>>
>> The --delete is important to delete files in DST that are not any more 
>> in SRC, otherwise you might get a weird mix up.
>>
>> Did you forget the --delete?
> 
> 
> No. It was on purpose not to run --delete.

Welcome to unknown territory.

As this may create a rather unusual mixup in the segment files that 
usually can not exist, I am not sure how good/bad borg can handle this.

Maybe the traceback you got is caused by this.

> And if borg reports that all segments are valid what corrupts the 
> segment reference count?

Could be that although each segment file looks valid (== all the crc32 
checks of its entries are ok), the overall state when looking at all 
segments in their on-disk order is not valid and is not produced by 
normal borg operations?

> My assumption is that borg will find and repair 
> the history with a last succeeding commit. Eg. borg backup has segment 
> 10480, the original repo 11050 than borg could find the last commit in 
> segment 11047. Is my assumption valid?

If your repo is in normal mode (NOT in append-only mode), 
compact_segments will shuffle data from older non-compact segments to 
newer (then compact) segments.

Thus, how data of misc. backup runs maps to segment files is maybe not 
as simple as you think it is.

>> I just checked in the code: borg check --repair rebuilds the hints and 
>> index from information found in the segment files only.
> 
> 
> So it should be fine to delete hints and index files on the repo and 
> call borg check --repair. Than the "usage count" and "freeable space" 
> should be fine?

Usually yes.


More information about the Borgbackup mailing list