diff --git a/cmd/restic/cmd_backup.go b/cmd/restic/cmd_backup.go index 26e5434f1..191a3037b 100644 --- a/cmd/restic/cmd_backup.go +++ b/cmd/restic/cmd_backup.go @@ -417,7 +417,7 @@ func runBackup(opts BackupOptions, gopts GlobalOptions, args []string) error { // Find last snapshot to set it as parent, if not already set if !opts.Force && parentSnapshotID == nil { - id, err := restic.FindLatestSnapshot(context.TODO(), repo, target, []restic.TagList{opts.Tags}, opts.Hostname) + id, err := restic.FindLatestSnapshot(context.TODO(), repo, target, []restic.TagList{}, opts.Hostname) if err == nil { parentSnapshotID = &id } else if err != restic.ErrNoSnapshotFound { diff --git a/cmd/restic/integration_test.go b/cmd/restic/integration_test.go index f83dd3c5c..dbc48703e 100644 --- a/cmd/restic/integration_test.go +++ b/cmd/restic/integration_test.go @@ -656,6 +656,7 @@ func TestBackupTags(t *testing.T) { rtest.Assert(t, newest != nil, "expected a new backup, got nil") rtest.Assert(t, len(newest.Tags) == 0, "expected no tags, got %v", newest.Tags) + parent := newest opts.Tags = []string{"NL"} testRunBackup(t, []string{env.testdata}, opts, env.gopts) @@ -664,6 +665,9 @@ func TestBackupTags(t *testing.T) { rtest.Assert(t, newest != nil, "expected a new backup, got nil") rtest.Assert(t, len(newest.Tags) == 1 && newest.Tags[0] == "NL", "expected one NL tag, got %v", newest.Tags) + // Tagged backup should have untagged backup as parent. + rtest.Assert(t, parent.ID.Equal(*newest.Parent), + "expected parent to be %v, got %v", parent.ID, newest.Parent) } func testRunTag(t testing.TB, opts TagOptions, gopts GlobalOptions) {