How to remove damaged Pack file?

So I had been using Restic for a few months for backup. Until I ran a full check of the repo. I got this error.

Pack ID does not match, want 5c35e993, got a4351f35
[5:59:10] 100.00%  79909 / 79909 packs...
Fatal: repository contains errors

I did a little bit reading on other forums where people have had this issue. The answer seems to be to be:

  1. Copy index
  2. Remove damaged pack file
  3. Rebuild index
  4. Do a backup --force

How do I remove this damaged pack file? If I go in the Data folder the file names are really long, and not like the Pack ID which is 8 characters long.

I did run a restic -r e:\restic-repo find --pack 5c35e993 command, which gave me a very long result:

Found blob 39542c72575db0e65545ba4cbad47f6a681ba906e4422e201d4402d5c9fa4f59
 ... in file /filename.jpg
     (tree e11e12af8716ebbb95c6388d11d197d9f86d1aaee3ed61510cbd854e179e5f12)
 ... in snapshot 14985708 (2022-04-29 13:05:35)

Great peice of software, but this error is making me a little skeptical now, especially with the fact that the simple --check option revealed no issues before hand, and the difficulty I’m having trying to resolve this.

There seems to be no --repair option also.

There is a file in one of the data folder starting with a4351f35, which is the pack file you’re looking for. Btw, have a look at Recover from broken pack file · Issue #828 · restic/restic · GitHub if you haven’t already.

Pack ID does not match, want 5c35e993, got a4351f35
[5:59:10] 100.00%  79909 / 79909 packs...
Fatal: repository contains errors

I can find 5c35e993 in the Data folder, but not, a4351f35.

If you run a sha256sum on the pack file starting with 5c35e993, it will most likely give you a4351f35… as result.
This is what the check is bailing: In restic all files (except config) should be named after their SHA256 sum. This file isn’t which means there is something wrong here.

Thanks, I understand that now. Filename should match sha256.

After removing the pack file I did the following:

  1. rebuild-index
  2. backup --force

I get the following message…

no parent snapshot found, will read all files

Does this mean the previous snapshots don’t have all the data intact? Will I have to now create a fresh backup?

It just implies that new backup attempt couldn’t find any previous related-snapshot and it needs to re-read files instead of comparing with a previous one.

What does check command says afterwards?

check --read-data command says, no errors found.

A couple of questions though,

  1. Am I correct in assuming that all previous snapshots have their data intact?
  2. Since I removed the damaged pack file, how are the previous snapshots still intact? What happened to the data that was in the corrupted pack file? Since these files are deltas (I’m guessing) shouldn’t the previous snapshots have data loss when I try to restore from them?
  3. Why couldn’t the backup find any previous related-snapshot? I’m backing up the same set of files. Intrestingly the data added to the repo was only about 52MB instead of the entire data set of few 100GBs.

Some partial answers from my knowledge:

Yes. If check --read-data says no errors, every current snapshot should have its data intact.

Was rebuild-index the only thing you run?

I ran rebuild-index followed by backup --force.

No, restic doesn’t save delta backups, but instead uses deduplication to achieve an even better effect when saving full backups. I advise you to read the doku and the link @MichaelEischer posted.

What most likely happened: You healed the repo (including all snapshots) by removing the pack file, running rebuild-index and then a backup, as decribed in the link above. BTW: for this procedure to work, you wouldn’t need to use --force.

By running backup --force you told restic not to search for a fitting snapshot a.k.a. parent snapshot. The message is is bit misleading, but the effect is the same as if restic would not be able to find a parent snapshot.

The 52MB come due to the deduplication. Having a parent or not doesn’t change anything w.r.t. the data written to the repo. A parent snapshot only alllows to speed up the backup.

1 Like