Fix restoring files as non-root user

As we cannot reliably detect in advance if we can set ownership, permissions,
timestamps or ext attributes, execute ALL the requested changes before
returning the first error we found.

Report total errors at end of restore and stop printing entire stacktraces
where just the error message is sufficient.

Fixes #655
This commit is contained in:
Pauline Middelink
2017-03-12 16:39:37 +01:00
parent 887e81188f
commit 642cd3bebf
2 changed files with 24 additions and 16 deletions

View File

@@ -103,8 +103,10 @@ func runRestore(opts RestoreOptions, gopts GlobalOptions, args []string) error {
Exitf(2, "creating restorer failed: %v\n", err)
}
totalErrors := 0
res.Error = func(dir string, node *restic.Node, err error) error {
Warnf("error for %s: %+v\n", dir, err)
Warnf("ignoring error for %s: %s\n", dir, err)
totalErrors++
return nil
}
@@ -134,5 +136,9 @@ func runRestore(opts RestoreOptions, gopts GlobalOptions, args []string) error {
Verbosef("restoring %s to %s\n", res.Snapshot(), opts.Target)
return res.RestoreTo(opts.Target)
err = res.RestoreTo(opts.Target)
if totalErrors > 0 {
Printf("There were %d errors\n", totalErrors)
}
return err
}