forked from TrueCloudLab/restic
Fix #3166
This commit is contained in:
parent
5e22ae10f1
commit
6e942693ba
2 changed files with 26 additions and 5 deletions
9
changelog/unreleased/issue-3166
Normal file
9
changelog/unreleased/issue-3166
Normal file
|
@ -0,0 +1,9 @@
|
|||
Bugfix: Improve error handling in restore
|
||||
|
||||
Restic restore used to not print errors while downloading file contents from
|
||||
the repository. restore also incorrectly exited with a zero error code even
|
||||
when there were errors during the restore process. Now, a non-zero code is
|
||||
returned.
|
||||
|
||||
https://github.com/restic/restic/issues/3166
|
||||
https://github.com/restic/restic/pull/3207
|
|
@ -191,14 +191,26 @@ func runRestore(opts RestoreOptions, gopts GlobalOptions, args []string) error {
|
|||
Verbosef("restoring %s to %s\n", res.Snapshot(), opts.Target)
|
||||
|
||||
err = res.RestoreTo(ctx, opts.Target)
|
||||
if err == nil && opts.Verify {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if totalErrors > 0 {
|
||||
return errors.Fatalf("There were %d errors\n", totalErrors)
|
||||
}
|
||||
|
||||
if opts.Verify {
|
||||
Verbosef("verifying files in %s\n", opts.Target)
|
||||
var count int
|
||||
count, err = res.VerifyFiles(ctx, opts.Target)
|
||||
Verbosef("finished verifying %d files in %s\n", count, opts.Target)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if totalErrors > 0 {
|
||||
Printf("There were %d errors\n", totalErrors)
|
||||
return errors.Fatalf("There were %d errors\n", totalErrors)
|
||||
}
|
||||
return err
|
||||
Verbosef("finished verifying %d files in %s\n", count, opts.Target)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue