mirror of
https://github.com/octoleo/restic.git
synced 2024-11-22 21:05:10 +00:00
restore: ignore errors
Also add a test for restoring a file that is owned by root. Closes #244.
This commit is contained in:
parent
b5ebd702fe
commit
deaca157fe
@ -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 {
|
||||
|
@ -206,6 +206,7 @@ func configureRestic(t testing.TB, cache, repo string) GlobalOptions {
|
||||
|
||||
password: TestPassword,
|
||||
stdout: os.Stdout,
|
||||
stderr: os.Stderr,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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),
|
||||
|
BIN
cmd/restic/testdata/repo-restore-permissions-test.tar.gz
vendored
Normal file
BIN
cmd/restic/testdata/repo-restore-permissions-test.tar.gz
vendored
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user