-
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
Restore code produces inconsistent timestamps/permissions #1212
Comments
I'll be working on this as time permits. |
This issue is still partially present in v0.9.4. I was able to reproduce the timestamp mismatch, but not the permissions one. |
I am able to reproduce both permissions and timestamp bugs on I took the above and turned it into a reproducible script. Note the #!/bin/bash
check_equal_permission()
{
echo "Comparing permissions on $1 to $2..."
(test $(stat -f %p $1) -eq $(stat -f %p $2) && echo "Passed!") || (echo "Comparison failed." && ls -ld $1 && ls -ld $2)
echo ""
}
check_equal_modified()
{
echo "Comparing modified dates on $1 to $2..."
(test $(stat -f %m $1) -eq $(stat -f %m $2) && echo "Passed!") || (echo "Comparison failed." && ls -ld $1 && ls -ld $2)
echo ""
}
check_file()
{
check_equal_permission $1 $2
check_equal_modified $1 $2
}
mkdir -p test/{foo,bar}
chmod 700 test/foo
touch -t 201901010000 test/{foo,bar}/{what,wut} test/{foo,bar} test
restic --password-command='echo pass' -r repo init
restic --password-command='echo pass' -r repo backup test
restic --password-command='echo pass' -r repo restore latest --include 'wut' --target restored
check_file test restored/test
check_file test/foo restored/test/foo
check_file test/bar restored/test/bar
rm -rf restored
restic --password-command='echo pass' -r repo restore latest --include 'foo' --target restored
check_file test restored/test
check_file test/foo restored/test/foo
rm -rf restored
restic --password-command='echo pass' -r repo restore latest --include 'test' --target restored
check_file test restored/test
check_file test/foo restored/test/foo
check_file test/bar restored/test/bar
restic --password-command='echo pass' -r repo restore latest --include '/test/**' --target restored
check_file test restored/test
check_file test/foo restored/test/foo
check_file test/bar restored/test/bar
rm -rf test repo restored I get the following output:
|
…nd root directory in special case Reproduce from restic#1212
…dForRestore to determine if we should visit leaveDir
Hello there, About the change :
I guess there is still something wrong, using the original reproductible script give me something new. More information : Using the simplified version script #!/bin/bash
export DEBUG_LOG=restic-debug.log
check_equal_permission()
{
echo "Comparing permissions on $1 to $2..."
(test $(stat -f %p $1) -eq $(stat -f %p $2) && echo "Passed!") || (echo "#### Comparison failed." && ls -ld $1 && ls -ld $2)
echo ""
}
check_equal_modified()
{
echo "Comparing modified dates on $1 to $2..."
(test $(stat -f %m $1) -eq $(stat -f %m $2) && echo "Passed!") || (echo "#### Comparison failed." && ls -ld $1 && ls -ld $2)
echo ""
}
check_file()
{
check_equal_permission $1 $2
check_equal_modified $1 $2
}
rm restic-debug.log
mkdir -p test/{dir1,dir2}
mkdir -p test/dir1/dir3/
chmod 700 test/dir1
chmod 700 test/dir1/dir3
touch -t 201901010000 test/{dir1,dir2}/{file1,file2} test/{dir1,dir2} test test/dir1/dir3/file3
restic --password-command='echo pass' -r repo init
restic --password-command='echo pass' -r repo backup test
rm restic-debug.log
restic --password-command='echo pass' -r repo restore latest --include 'file1' --target restored
check_file test restored/test
rm -rf test repo restored
err := res.traverseTree(ctx, dst, string(filepath.Separator), *res.sn.Tree, treeVisitor{
enterDir: func(node *restic.Node, target, location string) error {
debug.Log("first pass: enterDir mkdir %q, leaveDir should restore metadata", location)
// create dir with default permissions
// #leaveDir restores dir metadata after visiting all children
return fs.MkdirAll(target, 0700)
},
visitNode: func(node *restic.Node, target, location string) error {
debug.Log("first pass: visitNode mkdir %q, second pass (leaveDir) should restore metadata", location)
// create parent dir with default permissions
// second pass #leaveDir restores dir metadata after visiting/restoring all children
err := fs.MkdirAll(filepath.Dir(target), 0700)
after fixing we can see that the leaveDir is executed on the second tree pass :
The fix make pass all the reproductible original script. By the way, the fix broke one test
|
@kitone Please open a PR, that makes it way easier to discuss the implementation. |
…ions. Keep track of restored child status so parent and root directory not selected by filter will also restore metadata when traversing tree.
Done, PR fix the reproductible script (minus one broken test case) |
…ions. Keep track of restored child status so parent and root directory not selected by filter will also restore metadata when traversing tree.
…ions. Keep track of restored child status so parent and root directory not selected by filter will also restore metadata when traversing tree.
…ions. Keep track of restored child status so parent and root directory not selected by filter will also restore metadata when traversing tree.
…ions. Keep track of restored child status so parent and root directory not selected by filter will also restore metadata when traversing tree.
…ions. Keep track of restored child status so parent and root directory not selected by filter will also restore metadata when traversing tree.
…ions. Keep track of restored child status so parent and root directory not selected by filter will also restore metadata when traversing tree.
…ions. Keep track of restored child status so parent and root directory not selected by filter will also restore metadata when traversing tree.
…ions. Keep track of restored child status so parent and root directory not selected by filter will also restore metadata when traversing tree.
…ions. Keep track of restored child status so parent and root directory not selected by filter will also restore metadata when traversing tree.
…ions. Keep track of restored child status so parent and root directory not selected by filter will also restore metadata when traversing tree.
…ions. Keep track of restored child status so parent and root directory not selected by filter will also restore metadata when traversing tree.
…ions. Keep track of restored child status so parent and root directory not selected by filter will also restore metadata when traversing tree.
Follow-up to #982 and #1044, relevant info excerpted below.
Output of
restic version
How did you start restic exactly? (Include the complete command line)
See repro steps below.
What backend/server/service did you use?
Local + S3.
Expected behavior
Actual behavior
Steps to reproduce the behavior
Do you have any idea what may have caused this?
Yes.
The text was updated successfully, but these errors were encountered: