mirror of
https://github.com/octoleo/restic.git
synced 2024-12-23 11:28:54 +00:00
Merge pull request #2857 from MichaelEischer/incomplete-backup-error
Don't print a stacktrace if some files could not be read
This commit is contained in:
commit
48f97f3567
@ -98,8 +98,8 @@ type BackupOptions struct {
|
||||
|
||||
var backupOptions BackupOptions
|
||||
|
||||
// Error sentinel for invalid source data
|
||||
var InvalidSourceData = errors.New("Failed to read all source data during backup.")
|
||||
// ErrInvalidSourceData is used to report an incomplete backup
|
||||
var ErrInvalidSourceData = errors.New("failed to read all source data during backup")
|
||||
|
||||
func init() {
|
||||
cmdRoot.AddCommand(cmdBackup)
|
||||
@ -601,7 +601,7 @@ func runBackup(opts BackupOptions, gopts GlobalOptions, term *termstatus.Termina
|
||||
p.P("snapshot %s saved\n", id.Str())
|
||||
}
|
||||
if !success {
|
||||
return InvalidSourceData
|
||||
return ErrInvalidSourceData
|
||||
}
|
||||
|
||||
// Return error if any
|
||||
|
@ -515,7 +515,7 @@ func TestBackupErrors(t *testing.T) {
|
||||
gopts.stderr = ioutil.Discard
|
||||
err := testRunBackupAssumeFailure(t, filepath.Dir(env.testdata), []string{"testdata"}, opts, gopts)
|
||||
rtest.Assert(t, err != nil, "Assumed failure, but no error occured.")
|
||||
rtest.Assert(t, err == InvalidSourceData, "Wrong error returned")
|
||||
rtest.Assert(t, err == ErrInvalidSourceData, "Wrong error returned")
|
||||
snapshotIDs := testRunList(t, "snapshots", env.gopts)
|
||||
rtest.Assert(t, len(snapshotIDs) == 1,
|
||||
"expected one snapshot, got %v", snapshotIDs)
|
||||
|
@ -88,6 +88,8 @@ func main() {
|
||||
switch {
|
||||
case restic.IsAlreadyLocked(errors.Cause(err)):
|
||||
fmt.Fprintf(os.Stderr, "%v\nthe `unlock` command can be used to remove stale locks\n", err)
|
||||
case err == ErrInvalidSourceData:
|
||||
fmt.Fprintf(os.Stderr, "Warning: %v\n", err)
|
||||
case errors.IsFatal(errors.Cause(err)):
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
case err != nil:
|
||||
@ -106,7 +108,7 @@ func main() {
|
||||
switch err {
|
||||
case nil:
|
||||
exitCode = 0
|
||||
case InvalidSourceData:
|
||||
case ErrInvalidSourceData:
|
||||
exitCode = 3
|
||||
default:
|
||||
exitCode = 1
|
||||
|
Loading…
Reference in New Issue
Block a user