-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 restore #1044
Improve restore #1044
Conversation
Please ignore |
src/restic/filter/filter.go
Outdated
} | ||
|
||
patterns := strings.Split(pattern, "/") | ||
strs := strings.Split(str, "/") |
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.
There is duplication with Match
here. This will be dealt with.
src/restic/filter/filter_test.go
Outdated
{"/foo", "/foo/bar", true}, // maybe this should be false | ||
{"/*", "/foo", true}, // maybe this should be false | ||
{"/*", "/foo/bar", true}, // maybe this should be false | ||
{"/foo", "/foo/bar", true}, // maybe this should be 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.
There may be some semantic choice to be made here: /foo
and /foo/*
are equivalent to /foo/**
currently. Maybe a single *
could mean "restore just files at that level and foo
or /foo
mean "restore foo
but if it's a dir, don't go down". I kept the existing behavior as is.
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.
You're right, I like your suggestion. Make it so :) We'll need to document this, though.
I have an integration test failing locally, but I can't make sense of it yet (I haven't looked into it, but I will). |
Good, Appveyor reproduced the same failure |
src/cmds/restic/cmd_restore.go
Outdated
if err != nil { | ||
Warnf("error for exclude pattern: %v", err) | ||
} | ||
|
||
return !matched | ||
return !matched, !childMayMatch |
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.
Reverting that !
on childMayMatch
fixes the integration test.
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.
Do you know that you can just force-push reworked commits, and they will replace the commits here?
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.
Yes I do, serial abuser of rebase -i
over here :)
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.
Had to leave pronto just as I found the fix but wanted to let you know (AFK for now)
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.
Heh, nice. :)
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.
First few comments are in, having an in depth look now.
.gopath
Outdated
@@ -0,0 +1 @@ | |||
/Users/lloeki/Workspace/go |
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.
Remove this file from the PR
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.
Yep, SAVEPOINT commit
src/cmds/restic/cmd_restore.go
Outdated
} | ||
|
||
selectIncludeFilter := func(item string, dstpath string, node *restic.Node) bool { | ||
matched, err := filter.List(opts.Include, item) | ||
// This could return a `childMayMatch` bool and do some additional testing using filter.Match or something alike |
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.
Is this a work-in-progress comment?
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.
Yep, SAVEPOINT commit
src/restic/filter/filter_test.go
Outdated
{"/foo", "/foo/bar", true}, // maybe this should be false | ||
{"/*", "/foo", true}, // maybe this should be false | ||
{"/*", "/foo/bar", true}, // maybe this should be false | ||
{"/foo", "/foo/bar", true}, // maybe this should be 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.
You're right, I like your suggestion. Make it so :) We'll need to document this, though.
I haven't found any other issues, good work already! |
1daf014
to
23a950d
Compare
Regarding this:
I'd rather handle it in a separate issue/PR as this seems a bit more involved and I don't want to hold this PR back. |
@fd0 Would you like me to split this fix in a separate PR? I have not worked on it yet although I have some ideas for a fix. |
Codecov Report
@@ Coverage Diff @@
## master #1044 +/- ##
==========================================
- Coverage 52.96% 47.28% -5.68%
==========================================
Files 126 126
Lines 12035 12077 +42
==========================================
- Hits 6374 5711 -663
- Misses 4921 5677 +756
+ Partials 740 689 -51
Continue to review full report at Codecov.
|
Hmm, I had a hunch and tested this some more, and the behaviour for exclude filters is incorrect. |
Just to be sure I tested multiple include filters and it behaves as expected: |
b321293
to
45a2256
Compare
The exclusion case is now fixed and its performance improved as well. I made some variable names more explicit (notably semantic of matched vs selected) to make it easier to reason about the code. Tested cumulative excludes successfully: |
45a2256
to
0813770
Compare
Cool, let me know once you're satisfied with the PR and I'll have a look :) |
Sorry this fell off the radar, go for it! |
Hey, just a quick question: We're switching to the idiomatic Go repository layout (see #1116). May I convert your changes and force-push your branch? |
Sure :) |
Hm, it seems I'm not allowed to push into your branch. Could you please check if you've enabled this feature? https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/ Alternatively, just do a |
This improves restore performance by several orders of magniture by not going through the whole tree recursively when we can anticipate that no match will ever occur.
An exclude filter is basically a 'wildcard but foo', so even if a childMayMatch, other children of a dir may not, therefore childMayMatch does not matter, but we should not go down unless the dir is selected for restore.
0813770
to
f880ff2
Compare
Thanks a lot, I'll have a look! |
Please excuse the long time I sat on this PR. It looks great and I've merged it. Thanks a lot for your work! |
Awesome, many thanks! |
Would you like to continue working on the timestamps issue? |
If time is not of the essence on that front, yes I can get my hands on it. |
It isn't, but we should probably document that in an issue (and that you'll work on it sometime). |
OK, I created the issue. |
Awesome, thanks! |
This improves restore performance by several orders of magniture by not going through the whole tree recursively when we can anticipate that no match will ever occur.
Here is a sample run restoring one file from a
/
backup of a Debian machine on S3:/etc
(The error about
lchown
is spurious since I'm not running this as root)I have not included time from the current version since it just takes literally forever.
Timestamps and rights not being restored correctly will be the next unit of work once this is dealt with.
Fixes #982