Skip to content

Commit f294c81

Browse files
committed
Print stderr in all failed restic commands
This matches the behavior of "exec" and is essential to troubleshooting failures.
1 parent bb29a98 commit f294c81

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

internal/backend.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func (b Backend) validate() error {
133133
// Check if already initialized
134134
cmd := []string{"check"}
135135
cmd = append(cmd, combineBackendOptions("check", b)...)
136-
_, _, err = ExecuteResticCommand(options, cmd...)
136+
_, out, err := ExecuteResticCommand(options, cmd...)
137137
if err == nil {
138138
return nil
139139
} else {
@@ -142,6 +142,9 @@ func (b Backend) validate() error {
142142
cmd := []string{"init"}
143143
cmd = append(cmd, combineBackendOptions("init", b)...)
144144
_, _, err := ExecuteResticCommand(options, cmd...)
145+
if err != nil {
146+
colors.Error.Println(out)
147+
}
145148
return err
146149
}
147150
}

internal/location.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,12 @@ func (l Location) Backup(cron bool, dry bool, specificBackend string) []error {
288288
for k, v := range env2 {
289289
env[k+"2"] = v
290290
}
291-
_, _, err := ExecuteResticCommand(ExecuteOptions{
291+
_, out, err := ExecuteResticCommand(ExecuteOptions{
292292
Envs: env,
293293
}, "copy", md.SnapshotID)
294294

295295
if err != nil {
296+
colors.Error.Println(out)
296297
errors = append(errors, err)
297298
}
298299
}
@@ -358,8 +359,9 @@ func (l Location) Forget(prune bool, dry bool) error {
358359
cmd = append(cmd, "--dry-run")
359360
}
360361
cmd = append(cmd, combineAllOptions("forget", l, backend)...)
361-
_, _, err = ExecuteResticCommand(options, cmd...)
362+
_, out, err := ExecuteResticCommand(options, cmd...)
362363
if err != nil {
364+
colors.Error.Println(out)
363365
return err
364366
}
365367
}

0 commit comments

Comments
 (0)