Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
aawsome authored and mfrischknecht committed Jun 14, 2022
1 parent d513be6 commit 40d56c3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
9 changes: 9 additions & 0 deletions changelog/unreleased/issue-3166
Original file line number Diff line number Diff line change
@@ -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
22 changes: 17 additions & 5 deletions cmd/restic/cmd_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
if err != nil {
return err
}
if totalErrors > 0 {
return errors.Fatalf("There were %d errors\n", totalErrors)
}
Verbosef("finished verifying %d files in %s\n", count, opts.Target)
}
if totalErrors > 0 {
Printf("There were %d errors\n", totalErrors)
}
return err

return nil
}

0 comments on commit 40d56c3

Please sign in to comment.