From 84d8bbda247a7c7841ca74a1b2911fceeeed00da Mon Sep 17 00:00:00 2001 From: Lyndon-Li Date: Tue, 14 Nov 2023 10:40:20 +0800 Subject: [PATCH] issue 7094: fallback to full backup if previous snapshot is not found Signed-off-by: Lyndon-Li --- changelogs/unreleased/7097-Lyndon-Li | 1 + pkg/uploader/kopia/snapshot.go | 6 +++--- pkg/uploader/kopia/snapshot_test.go | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 changelogs/unreleased/7097-Lyndon-Li diff --git a/changelogs/unreleased/7097-Lyndon-Li b/changelogs/unreleased/7097-Lyndon-Li new file mode 100644 index 0000000000..7ce3312485 --- /dev/null +++ b/changelogs/unreleased/7097-Lyndon-Li @@ -0,0 +1 @@ +Fix issue #7094, fallback to full backup if previous snapshot is not found \ No newline at end of file diff --git a/pkg/uploader/kopia/snapshot.go b/pkg/uploader/kopia/snapshot.go index 27ac842532..d87404a36b 100644 --- a/pkg/uploader/kopia/snapshot.go +++ b/pkg/uploader/kopia/snapshot.go @@ -236,10 +236,10 @@ func SnapshotSource( mani, err := loadSnapshotFunc(ctx, rep, manifest.ID(parentSnapshot)) if err != nil { - return "", 0, errors.Wrapf(err, "Failed to load previous snapshot %v from kopia", parentSnapshot) + log.WithError(err).Warnf("Failed to load previous snapshot %v from kopia, fallback to full backup", parentSnapshot) + } else { + previous = append(previous, mani) } - - previous = append(previous, mani) } else { log.Infof("Searching for parent snapshot") diff --git a/pkg/uploader/kopia/snapshot_test.go b/pkg/uploader/kopia/snapshot_test.go index 65ec22136a..34bc530b29 100644 --- a/pkg/uploader/kopia/snapshot_test.go +++ b/pkg/uploader/kopia/snapshot_test.go @@ -112,7 +112,7 @@ func TestSnapshotSource(t *testing.T) { notError: true, }, { - name: "failed to load snapshot", + name: "failed to load snapshot, should fallback to full backup and not error", args: []mockArgs{ {methodName: "LoadSnapshot", returns: []interface{}{manifest, errors.New("failed to load snapshot")}}, {methodName: "SaveSnapshot", returns: []interface{}{manifest.ID, nil}}, @@ -122,7 +122,7 @@ func TestSnapshotSource(t *testing.T) { {methodName: "Upload", returns: []interface{}{manifest, nil}}, {methodName: "Flush", returns: []interface{}{nil}}, }, - notError: false, + notError: true, }, { name: "failed to save snapshot",