issue 7094: fallback to full backup if previous snapshot is not found

Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
Lyndon-Li
2023-11-14 10:40:20 +08:00
parent 86e34eec28
commit 84d8bbda24
3 changed files with 6 additions and 5 deletions

View File

@@ -0,0 +1 @@
Fix issue #7094, fallback to full backup if previous snapshot is not found

View File

@@ -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")

View File

@@ -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",