From a33b782c547bb8a36e0d4490a3506ca52b8f9520 Mon Sep 17 00:00:00 2001 From: simonhammes Date: Wed, 30 Oct 2024 15:47:34 +0100 Subject: [PATCH] Add allowFailure option Implements #189 --- internal/backend.go | 17 +++++++++-------- internal/location.go | 7 +++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/internal/backend.go b/internal/backend.go index 26eadac..24f0e2b 100644 --- a/internal/backend.go +++ b/internal/backend.go @@ -19,14 +19,15 @@ type BackendRest struct { } type Backend struct { - name string - Type string `mapstructure:"type,omitempty" yaml:"type,omitempty"` - Path string `mapstructure:"path,omitempty" yaml:"path,omitempty"` - Key string `mapstructure:"key,omitempty" yaml:"key,omitempty"` - RequireKey bool `mapstructure:"requireKey,omitempty" yaml:"requireKey,omitempty"` - Env map[string]string `mapstructure:"env,omitempty" yaml:"env,omitempty"` - Rest BackendRest `mapstructure:"rest,omitempty" yaml:"rest,omitempty"` - Options Options `mapstructure:"options,omitempty" yaml:"options,omitempty"` + name string + Type string `mapstructure:"type,omitempty" yaml:"type,omitempty"` + Path string `mapstructure:"path,omitempty" yaml:"path,omitempty"` + Key string `mapstructure:"key,omitempty" yaml:"key,omitempty"` + RequireKey bool `mapstructure:"requireKey,omitempty" yaml:"requireKey,omitempty"` + AllowFailure bool `mapstructure:"allowFailure,omitempty" yaml:"allowFailure,omitempty"` + Env map[string]string `mapstructure:"env,omitempty" yaml:"env,omitempty"` + Rest BackendRest `mapstructure:"rest,omitempty" yaml:"rest,omitempty"` + Options Options `mapstructure:"options,omitempty" yaml:"options,omitempty"` } func GetBackend(name string) (Backend, bool) { diff --git a/internal/location.go b/internal/location.go index 221c5f3..cff2eb2 100644 --- a/internal/location.go +++ b/internal/location.go @@ -267,6 +267,13 @@ func (l Location) Backup(cron bool, specificBackend string) []error { // If error save it and continue if err != nil { + if backend.AllowFailure { + colors.Faint.Printf("skipping backend \"%s\" since allowFailure was set to \"true\"\n", to) + if flags.VERBOSE { + colors.Error.Printf("reason: %s", out) + } + continue + } colors.Error.Println(out) errors = append(errors, fmt.Errorf("%s@%s:\n%s%s", l.name, backend.name, out, err)) continue