-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Improve recover command #2880
Improve recover command #2880
Conversation
2c80985
to
bea3a5f
Compare
rebased this to resolve the merge conflicts. |
bea3a5f
to
bf5931a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that the recover
command needs that many flags. For me it looks like --all=false
is the behavior everyone would. --all=true
just clutters the recovered snapshot(s). Now with the new prune implementation, there will be hundred or thousands of "root" trees in the repository, which makes --combine=false
essentially useless in my opinion. When recover
only creates a single snapshot, I don't see much use for a --dry-run
option either, in the worst case recover
will create a single snapshot which is also tagged accordingly.
--all=false --combine=false
will not really recover deleted snapshots, these still miss all metadata.
cmd/restic/cmd_recover.go
Outdated
recoverFlags := cmdRecover.Flags() | ||
recoverFlags.BoolVar(&recoverOptions.All, "all", false, "add all directories, not only unreferenced ones") | ||
recoverFlags.BoolVar(&recoverOptions.Combine, "combine", true, "if true, combine all directories into one snapshot, else generate multple snapshots") | ||
recoverFlags.BoolVarP(&recoverOptions.DryRun, "dry-run", "n", false, "only show what would be done") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--dry-run
only seems to be useful in combination with --combine=false
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another use case would be to use it for debugging/troubleshooting which would also work on read-only repositories.
ae8dc42
to
0f2fe6a
Compare
What's the use case of tagging a snapshot created by Also, I don't understand the point of having a boolean argument to |
With
You are right. Of course |
rebased to solve merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not convinced about the --split
option as it just feels like a crutch to me. After all, the whole metadata of a snapshot is still lost in the process. So, I'd like to limit this PR to the code cleanups and tweaks, but defer new options to a discussion on how "un-deleting" a snapshot could/should work.
Please remove the --split
and the then obsolete --dry-run
and --tags
options. The factored out createSnapshot
function can stay though.
tree, err := repo.LoadTree(gopts.ctx, id) | ||
if err != nil { | ||
Warnf("unable to load tree %v: %v\n", id.Str(), err) | ||
continue | ||
} | ||
|
||
for _, node := range tree.Nodes { | ||
if node.Type != "dir" || node.Subtree == nil { | ||
continue | ||
if node.Type == "dir" && node.Subtree != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a follow-up PR it would be possible to introduce a ForAllTrees
function similar to ForAllSnapshots
etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very true 👍
Let's see when I'll find some time for it 😉
- only save directories not referenced by any snapshot - dont't write empty snapshot - use progress bar
fac12d3
to
bce8792
Compare
I'm fine with postponing the '--split' or something else to a future PR.
Is removed. Hope these small improvements are nevertheless helpful! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Excluding trees belonging to snapshot might be quite helpful, especially for a repository containing lots of snapshots. And the code cleanup is also a plus :-) .
What does this PR change? What problem does it solve?
Enhance the
recover
command to make it useful in more recovery situations:OLD AND REMOVED:
Was the change discussed in an issue or in the forum before?
no.
Checklist
recover
so farchangelog/unreleased/
that describes the changes for our users (template here)gofmt
on the code in all commits