Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add repair packs command to simplify recovery from damaged pack #4530

Merged
merged 3 commits into from Oct 23, 2023

Conversation

MichaelEischer
Copy link
Member

What does this PR change? What problem does it solve?

Adds a repair packs command that salvages all intact blobs from the specified pack files and updates the index accordingly. The salvaged pack files are written to the current folder, and the broken pack files are removed from the repository.

Without this PR, the only way to recover from pack files with broken blobs is to either remove all snapshots that use those blobs followed by a prune run, removing the whole pack files or using a debug build of restic to run restic debug examine --reupload-blobs followed by manually removing the pack file and repairing the index.

The repair packs command is marked as experimental and introduces a stub feature flag implementation. The idea is to only enable experimental commands if the feature flag is set. The flag contains a version number which will be incremented in case of incompatible changes, this causes all invocations using the old flag version to fail. Feature flags and the corresponding commands may be removed/changed between restic versions without notice.

Was the change previously discussed in an issue or on the forum?

No, however, #4523 might make it necessary to provide a more user friendly way to repair repositories.

Checklist

  • I have read the contribution guidelines.
  • I have enabled maintainer edits.
  • I have added tests for all code changes.
  • I have added documentation for relevant changes (in the manual).
  • There's a new file in changelog/unreleased/ that describes the changes for our users (see template).
  • I have run gofmt on the code in all commits.
  • All commit messages are formatted in the same style as the other commits in the repo.
  • I'm done! This pull request is ready for review.

This allows recovering a repository from several cases of damaged blobs.
For now, the guide is only shown if the blob content does not match its
hash. The main intended usage is to handle data corruption errors when
using maximum compression in restic 0.16.0
Copy link
Member Author

@MichaelEischer MichaelEischer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I'll add a test later on. There's no documentation for now as the only intended usage is to repair the data corruption issues fixed by #4532, the check command provides the necessary instructions to fix those. A pack file can be damaged in other ways which have to be handled separately.

@MichaelEischer MichaelEischer merged commit 9707956 into restic:master Oct 23, 2023
13 checks passed
@MichaelEischer MichaelEischer deleted the repair-packs branch October 23, 2023 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant