Skip to content

Commit

Permalink
Add allowFailure option
Browse files Browse the repository at this point in the history
Implements #189
  • Loading branch information
simonhammes committed Oct 30, 2024
1 parent 8a77385 commit a5af001
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
17 changes: 9 additions & 8 deletions internal/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ type BackendRest struct {
}

type Backend struct {
name string
Type string `mapstructure:"type,omitempty"`
Path string `mapstructure:"path,omitempty"`
Key string `mapstructure:"key,omitempty"`
RequireKey bool `mapstructure:"requireKey,omitempty"`
Env map[string]string `mapstructure:"env,omitempty"`
Rest BackendRest `mapstructure:"rest,omitempty"`
Options Options `mapstructure:"options,omitempty"`
name string
Type string `mapstructure:"type,omitempty"`
Path string `mapstructure:"path,omitempty"`
Key string `mapstructure:"key,omitempty"`
RequireKey bool `mapstructure:"requireKey,omitempty"`
AllowFailure bool `mapstructure:"allowFailure,omitempty"`
Env map[string]string `mapstructure:"env,omitempty"`
Rest BackendRest `mapstructure:"rest,omitempty"`
Options Options `mapstructure:"options,omitempty"`
}

func GetBackend(name string) (Backend, bool) {
Expand Down
7 changes: 7 additions & 0 deletions internal/location.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a5af001

Please sign in to comment.