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 bitrot detection to "diff" command #4526

Merged
merged 3 commits into from Jan 6, 2024

Conversation

dnnr
Copy link
Contributor

@dnnr dnnr commented Oct 20, 2023

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

This introduces a new modifier to the output of the diff command. It appears whenever two files being compared only differ in their content but not in their metadata. As far as we know, under normal circumstances, this should only ever happen if some kind of bitrot has happened in the source file. The prerequisite for this detection to work is that the right-side snapshot of the comparison has been created with "backup --force".

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

See #805

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.

@dnnr
Copy link
Contributor Author

dnnr commented Oct 20, 2023

Sadly, I couldn't figure out a good way to test this... I did however verify it manually.

I also feel like some more verbose documentation could be useful (along the lines of the commit message), but I wasn't sure where to put it. Any suggestions? The section in 040_backup.rst is pretty compact and most likely isn't the appropriate place for that kind of detail.

@dnnr dnnr force-pushed the detect-bitrot-in-diff branch 2 times, most recently from e598d2a to 142e4e4 Compare October 21, 2023 08:18
@MichaelEischer
Copy link
Member

The section in 040_backup.rst is pretty compact and most likely isn't the appropriate place for that kind of detail.

The explanation of the diff command feels completely out of place in 040_backup.rst. Let's move it to 045_working_with_repos.rst, which would also provide the room necessary for additional explanations.

Sadly, I couldn't figure out a good way to test this... I did however verify it manually.

What might work is the following: backup now supports the --stdin-from-command option which allows creating a snapshot with a certain content and choosing the file timestamp using the --time parameter, see TestStdinFromCommand for how to use it in tests. That combination allows us to reliably choose the metadata and content of the file. In particular, it also allows changing the file content without changing any metadata.

The other alternative would be to enhance the code at internal/restic/restic.go to allow creating a snapshot with bitrot. But that's likely the more complex path.

changelog/unreleased/pull-4526 Outdated Show resolved Hide resolved
changelog/unreleased/pull-4526 Show resolved Hide resolved
cmd/restic/cmd_diff.go Outdated Show resolved Hide resolved
cmd/restic/cmd_diff.go Outdated Show resolved Hide resolved
dnnr and others added 3 commits January 6, 2024 20:12
This introduces a new modifier to the output of the diff command. It
appears whenever two files being compared only differ in their content
but not in their metadata. As far as we know, under normal
circumstances, this should only ever happen if some kind of bitrot has
happened in the source file. The prerequisite for this detection to work
is that the right-side snapshot of the comparison has been created with
"backup --force".
Copy link
Member

@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.

@MichaelEischer MichaelEischer added this pull request to the merge queue Jan 6, 2024
Merged via the queue into restic:master with commit b2b7669 Jan 6, 2024
12 checks passed
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

2 participants