mirror of
https://github.com/octoleo/restic.git
synced 2024-12-26 20:30:19 +00:00
fix #1143
Backup was choosing a parent snapshot that had the same tags, which makes backup unnecessarily slow when there are newer snapshots with different tags. There's no reason parent has to have the same tags. This change makes backup choose the newest snapshot instead.
This commit is contained in:
parent
1dcfd64028
commit
7b44fd0f9d
@ -416,7 +416,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 {
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user