diff --git a/pkg/restic/restic.go b/pkg/restic/restic.go index 116e214165..0881a439ff 100644 --- a/pkg/restic/restic.go +++ b/pkg/restic/restic.go @@ -46,17 +46,6 @@ func shCommand(command string) []string { return []string{"bash", "-o", "errexit", "-o", "pipefail", "-c", command} } -// BackupCommandByID returns restic backup command -func BackupCommandByID(profile *param.Profile, repository, pathToBackup, encryptionKey string) ([]string, error) { - cmd, err := resticArgs(profile, repository, encryptionKey) - if err != nil { - return nil, err - } - cmd = append(cmd, "backup", pathToBackup) - command := strings.Join(cmd, " ") - return shCommand(command), nil -} - // BackupCommandByTag returns restic backup command with tag func BackupCommandByTag(profile *param.Profile, repository, backupTag, includePath, encryptionKey string) ([]string, error) { cmd, err := resticArgs(profile, repository, encryptionKey) @@ -134,17 +123,6 @@ func InitCommand(profile *param.Profile, repository, encryptionKey string) ([]st return shCommand(command), nil } -// ForgetCommandByTag returns restic forget command -func ForgetCommandByTag(profile *param.Profile, repository, tag, encryptionKey string) ([]string, error) { - cmd, err := resticArgs(profile, repository, encryptionKey) - if err != nil { - return nil, err - } - cmd = append(cmd, "forget", "--tag", tag) - command := strings.Join(cmd, " ") - return shCommand(command), nil -} - // ForgetCommandByID returns restic forget command func ForgetCommandByID(profile *param.Profile, repository, id, encryptionKey string) ([]string, error) { cmd, err := resticArgs(profile, repository, encryptionKey) @@ -449,25 +427,6 @@ func DoesRepoExist(output string) bool { return strings.Contains(output, "Is there a repository at the following location?") } -// SnapshotIDFromSnapshotLog gets the SnapshotID from Snapshot Command log -func SnapshotIDsFromSnapshotCommand(output string) ([]string, error) { - var snapIds []string - var result []map[string]interface{} - err := json.Unmarshal([]byte(output), &result) - if err != nil { - return nil, errors.WithMessage(err, "Failed to unmarshall output from snapshotCommand") - } - if len(result) == 0 { - return nil, errors.New("Snapshots not found") - } - for _, r := range result { - if r["short_id"] != nil { - snapIds = append(snapIds, r["short_id"].(string)) - } - } - return snapIds, nil -} - // SpaceFreedFromPruneLog gets the space freed from the prune log output // For reference, here is the logging command from restic codebase: // diff --git a/pkg/restic/restic_test.go b/pkg/restic/restic_test.go index 123deb3a3c..b6f95c9f35 100644 --- a/pkg/restic/restic_test.go +++ b/pkg/restic/restic_test.go @@ -318,22 +318,6 @@ func (s *ResticDataSuite) TestGetSnapshotStatsModeFromStatsLog(c *C) { } } -func (s *ResticDataSuite) TestGetSnapshotIDsFromSnapshotCommand(c *C) { - for _, tc := range []struct { - log string - expected []string - checker Checker - }{ - {log: `[{"time":"2019-03-28T17:35:15.146526-07:00","hostname":"MacBook-Pro.local","username":"abc","uid":501,"gid":20,"tags":["backup123"],"id":"7c0bfeb93dd5b390a6eaf8a386ec8cb86e4631f2d96400407b529b53d979536a","short_id":"7c0bfeb9"}]`, expected: []string{"7c0bfeb9"}, checker: IsNil}, - {log: `[{"time":"2019-03-28T17:35:15.146526-07:00","hostname":"MacBook-Pro.local","username":"abc","uid":501,"gid":20,"tags":["backup123"],"id":"7c0bfeb93dd5b390a6eaf8a386ec8cb86e4631f2d96400407b529b53d979536a","short_id":"7c0bfeb67"},{"time":"2019-03-28T17:35:15.146526-07:00","hostname":"MacBook-Pro.local","username":"abc","uid":501,"gid":20,"tags":["backup123"],"id":"7c0bfeb93dd5b390a6eaf8a386ec8cb86e4631f2d96400407b529b53d979536a","short_id":"7c0bfeb9"}]`, expected: []string{"7c0bfeb67", "7c0bfeb9"}, checker: IsNil}, - {log: `null`, expected: []string(nil), checker: NotNil}, - } { - ids, err := SnapshotIDsFromSnapshotCommand(tc.log) - c.Assert(err, tc.checker) - c.Assert(ids, DeepEquals, tc.expected) - } -} - func (s *ResticDataSuite) TestIsPasswordIncorrect(c *C) { for _, tc := range []struct { log string