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

Diagnostic command to display what snapshots a blob/tree belongs to #1777

Closed
McKael opened this issue May 12, 2018 · 3 comments
Closed

Diagnostic command to display what snapshots a blob/tree belongs to #1777

McKael opened this issue May 12, 2018 · 3 comments

Comments

@McKael
Copy link
Contributor

McKael commented May 12, 2018

This is not a bug report but a feature proposal.

A few times, I've been missing a command to list the snapshots that contain a specific tree or blob, or the snapshots affected by a corrupted pack.

I'd like to be able to use a restic command for this case (AFAIK it does not exist yet) and I've written some POC code.
I can do a PR to discuss this further if this suggestion sounds reasonable to you.

Here's a practical example.

% restic check
repository a04959d0 opened successfully, password is correct
create exclusive lock for repository
load indexes
check all packs
check snapshots, trees and blobs
(...)
error for tree e437ff75:
  tree e437ff75: file "checks.db": metadata size (122171392) and sum of blob sizes (122175488) do not match
Fatal: repository contains errors

Let's check what this tree actually is and which snapshot is affected.

% restic what-contains tree e437ff75
repository a04959d0 opened successfully, password is correct
Found tree e437ff75
 ... path /mikael/check-data
 ... in snapshot f120bfbf

Here's another example with a random blob in one of my repositories:

% restic what-contains blob 9dcf5f6a254fb58c8b2a7e604dc76b71fbad847f6ade751513968cf2f1f161fc
repository a04959d0 opened successfully, password is correct
Blob found in pack cf8a3fa3b2c9c7a08b6b6fc6cce9fdc2eeb4dd26ebd2d67b081d63f24dd408d8
 ... Pack cf8a3fa3: <Blob (data) 9dcf5f6a, offset 2486760, length 12214>
Found blob 9dcf5f6a254fb58c8b2a7e604dc76b71fbad847f6ade751513968cf2f1f161fc
 ... in file 1398431273.H215567P22415.mail.example.com:2,
 ... in snapshot 067f149f
Found blob 9dcf5f6a254fb58c8b2a7e604dc76b71fbad847f6ade751513968cf2f1f161fc
 ... in file 1398431273.H215567P22415.mail.example.com:2,
 ... in snapshot 0a781e61
Found blob 9dcf5f6a254fb58c8b2a7e604dc76b71fbad847f6ade751513968cf2f1f161fc
 ... in file 1398431273.H215567P22415.mail.example.com:2,
 ... in snapshot 15ab2468
(...)

I'd also like to be able to do

% restic what-contains pack cf8a3fa3

but I haven't had a look at it yet.

Please let me know if it would be useful to other people than me.

@McKael
Copy link
Contributor Author

McKael commented May 13, 2018

I have added support for packs (see the PR):

% restic what-contains pack 0014cae1664cda85b69d22c3e0d86fe56085aebc3333613b7a956ea854dab118
repository a04959d0 opened successfully, password is correct
Looking for packs...
Found pack 0014cae1664cda85b69d22c3e0d86fe56085aebc3333613b7a956ea854dab118
33 blobs found
Found blob 1c4925a45401e8ecf71c2dc1a0294a823419839b122c80c973c7fc95d0a8a87b
 ... in file ____init____.py.i
 ... in snapshot 00ccb2af
Found blob 909975ec21ccf6b28c05a88a7281a0b3fd7ee235d31eec73eced46ef2efd9835
 ... in file posix.py.i
 ... in snapshot 00ccb2af
Found blob 46dbe70ab31e84c542bb0b226cd3bce0d33bc0807b56ab37f434eae32cc07692
 ... in file ch02_19.htm
 ... in snapshot 5b7eca88
(...)

@fd0
Copy link
Member

fd0 commented Jun 8, 2018

This looks great, thank you so much for spending time on it! I'm currently swamped with other real-life issues, and I've got a huge backlog of things to review. Sorry for that!

@fd0 fd0 added the feature label Jun 8, 2018
@McKael
Copy link
Contributor Author

McKael commented Sep 29, 2018

Closing this issue as the Merge Request #1780 has been accepted.

@McKael McKael closed this as completed Sep 29, 2018
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

No branches or pull requests

2 participants