diff --git a/cmd/restic/cmd_restore.go b/cmd/restic/cmd_restore.go index cb74f4768..26ef9b9e0 100644 --- a/cmd/restic/cmd_restore.go +++ b/cmd/restic/cmd_restore.go @@ -76,7 +76,7 @@ func (cmd CmdRestore) Execute(args []string) error { res.Error = func(dir string, node *restic.Node, err error) error { cmd.global.Warnf("error for %s: %+v\n", dir, err) - return err + return nil } selectExcludeFilter := func(item string, dstpath string, node *restic.Node) bool { diff --git a/cmd/restic/integration_helpers_test.go b/cmd/restic/integration_helpers_test.go index fe794ab1e..6fd90ac3f 100644 --- a/cmd/restic/integration_helpers_test.go +++ b/cmd/restic/integration_helpers_test.go @@ -206,6 +206,7 @@ func configureRestic(t testing.TB, cache, repo string) GlobalOptions { password: TestPassword, stdout: os.Stdout, + stderr: os.Stderr, } } diff --git a/cmd/restic/integration_test.go b/cmd/restic/integration_test.go index 999ad5a83..ed8cf3f3b 100644 --- a/cmd/restic/integration_test.go +++ b/cmd/restic/integration_test.go @@ -203,6 +203,7 @@ func TestBackupMissingFile1(t *testing.T) { cmdInit(t, global) + global.stderr = ioutil.Discard ranHook := false debug.Hook("pipe.walk1", func(context interface{}) { pathname := context.(string) @@ -240,6 +241,7 @@ func TestBackupMissingFile2(t *testing.T) { cmdInit(t, global) + global.stderr = ioutil.Discard ranHook := false debug.Hook("pipe.walk2", func(context interface{}) { pathname := context.(string) @@ -542,6 +544,31 @@ func TestRestoreFilter(t *testing.T) { }) } +func TestRestoreWithPermissionFailure(t *testing.T) { + withTestEnvironment(t, func(env *testEnvironment, global GlobalOptions) { + datafile := filepath.Join("testdata", "repo-restore-permissions-test.tar.gz") + SetupTarTestFixture(t, env.base, datafile) + + snapshots := cmdList(t, global, "snapshots") + Assert(t, len(snapshots) > 0, + "no snapshots found in repo (%v)", datafile) + + global.stderr = ioutil.Discard + cmdRestore(t, global, filepath.Join(env.base, "restore"), snapshots[0]) + + // make sure that all files have been restored, regardeless of any + // permission errors + files := cmdLs(t, global, snapshots[0].String()) + for _, filename := range files { + fi, err := os.Lstat(filepath.Join(env.base, "restore", filename)) + OK(t, err) + + Assert(t, !isFile(fi) || fi.Size() > 0, + "file %v restored, but filesize is 0", filename) + } + }) +} + func setZeroModTime(filename string) error { var utimes = []syscall.Timespec{ syscall.NsecToTimespec(0), diff --git a/cmd/restic/testdata/repo-restore-permissions-test.tar.gz b/cmd/restic/testdata/repo-restore-permissions-test.tar.gz new file mode 100644 index 000000000..36aa62dbf Binary files /dev/null and b/cmd/restic/testdata/repo-restore-permissions-test.tar.gz differ