Extend SnapshotOptions w/ command data

In order to determine whether to save a snapshot, we need to capture the exit code returned by a command. In order to provide a nice error message, we supply stderr as well.

Signed-off-by: Sebastian Hoß <seb@xn--ho-hia.de>
This commit is contained in:
Sebastian Hoß 2023-03-16 07:47:31 +01:00 committed by Michael Eischer
parent a2b76ff34f
commit 25350a9c55
2 changed files with 6 additions and 0 deletions

View File

@ -676,6 +676,8 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, ter
Hostname: opts.Host, Hostname: opts.Host,
ParentSnapshot: parentSnapshot, ParentSnapshot: parentSnapshot,
ProgramVersion: "restic " + version, ProgramVersion: "restic " + version,
Command: command,
CommandStderr: stderr,
} }
if !gopts.JSON { if !gopts.JSON {

View File

@ -2,7 +2,9 @@ package archiver
import ( import (
"context" "context"
"io"
"os" "os"
"os/exec"
"path" "path"
"runtime" "runtime"
"sort" "sort"
@ -681,6 +683,8 @@ type SnapshotOptions struct {
Time time.Time Time time.Time
ParentSnapshot *restic.Snapshot ParentSnapshot *restic.Snapshot
ProgramVersion string ProgramVersion string
Command *exec.Cmd
CommandStderr io.ReadCloser
} }
// loadParentTree loads a tree referenced by snapshot id. If id is null, nil is returned. // loadParentTree loads a tree referenced by snapshot id. If id is null, nil is returned.