mirror of
https://github.com/restic/restic.git
synced 2026-04-28 15:29:26 +00:00
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user