2
2
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:
Alexander Neumann 2015-07-25 12:58:55 +02:00
parent b5ebd702fe
commit deaca157fe
4 changed files with 29 additions and 1 deletions

View File

@ -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 {

View File

@ -206,6 +206,7 @@ func configureRestic(t testing.TB, cache, repo string) GlobalOptions {
password: TestPassword,
stdout: os.Stdout,
stderr: os.Stderr,
}
}

View File

@ -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),

Binary file not shown.