Skip to content

Commit

Permalink
Merge pull request #28 from YannikBramkamp/bugfix-restic-forget
Browse files Browse the repository at this point in the history
fix error related to restic forget json-logging
  • Loading branch information
Lucaber authored Feb 23, 2021
2 parents 051583d + 0afccc7 commit 4e21fd1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
12 changes: 10 additions & 2 deletions pkg/restic/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"strings"
"time"

"github.com/pkg/errors"

"github.com/mittwald/brudi/pkg/cli"
)

Expand Down Expand Up @@ -302,6 +304,7 @@ func Forget(
var args []string
args = cli.StructToCLI(globalOpts)
args = append(args, cli.StructToCLI(forgetOpts)...)
args = append(args, "--json")

cmd := cli.CommandType{
Binary: binary,
Expand All @@ -313,9 +316,14 @@ func Forget(
if err != nil {
return nil, out, err
}
if len(out) == 0 {
return nil, out, errors.New("no restic forget output, check your flag config")
}

var deletedSnapshots []string
var forgetResponse ForgetResponse
err = json.Unmarshal(out, &forgetResponse)
var forgetTags []*ForgetTag
err = json.Unmarshal(out, &forgetTags)
forgetResponse := ForgetResponse{Tags: forgetTags}
if err != nil {
return nil, out, err
}
Expand Down
15 changes: 8 additions & 7 deletions test/pkg/source/redisdump/redisdump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func redisDoBackup(ctx context.Context, useRestic bool,
}

// perform backup action on first redis container
err = source.DoBackupForKind(ctx, dumpKind, false, useRestic, false)
err = source.DoBackupForKind(ctx, dumpKind, false, useRestic, true)
if err != nil {
return testStruct{}, errors.WithStack(err)
}
Expand Down Expand Up @@ -343,12 +343,13 @@ restic:
repo: rest:http://%s:%s/
forget:
flags:
keepLast: 1
keepHourly: 0
keepDaily: 0
keepWeekly: 0
keepMonthly: 0
keepYearly: 0
keepDaily: 7
keepHourly: 24
keepLast: 48
keepMonthly: 6
keepWeekly: 2
keepYearly: 2
ids: []
restore:
flags:
target: "/"
Expand Down

0 comments on commit 4e21fd1

Please sign in to comment.