full backup if prev snapshots have no details (#2049)

## Description

In the event that a backup is completed but the details, somehow, isn't persisted, we want the next backup to do a full, instead of an incremental, backup.  If we don't have this protection the following backups could end up in a bad state.  Future changes will add better resilience so that the fallback isn't needed.

## Does this PR need a docs update or release note?

- [x]  No 

## Type of change

- [x] 🌻 Feature

## Issue(s)

* #1878

## Test Plan

- [x] 💚 E2E
This commit is contained in:
Keepers 2023-01-06 15:47:16 -07:00 committed by GitHub
parent d8763298ce
commit 70a8f53d65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 4 deletions

View File

@ -322,11 +322,9 @@ func fetchPrevSnapshotManifests(
// If the manifest already exists and it's incomplete then we should
// merge the reasons for consistency. This will become easier to handle
// once we update how checkpoint manifests are tagged.
if len(found.IncompleteReason) == 0 {
continue
if len(found.IncompleteReason) > 0 {
found.Reasons = append(found.Reasons, m.Reasons...)
}
found.Reasons = append(found.Reasons, m.Reasons...)
}
}
}

View File

@ -283,6 +283,31 @@ func produceManifestsAndMetadata(
continue
}
tk, _ := kopia.MakeTagKV(kopia.TagBackupID)
bID := man.Tags[tk]
if len(bID) == 0 {
return nil, nil, errors.New("missing backup id in prior manifest")
}
dID, _, err := sw.GetDetailsIDFromBackupID(ctx, model.StableID(bID))
if err != nil {
return nil, nil, errors.Wrap(err, "retrieving prior backup data")
}
// if no detailsID exists for any of the complete manifests, we want
// to fall back to a complete backup. This is a temporary prevention
// mechanism to keep backups from falling into a perpetually bad state.
// This makes an assumption that the ID points to a populated set of
// details; we aren't doing the work to look them up.
if len(dID) == 0 {
logger.Ctx(ctx).Infow(
"backup missing details ID, falling back to full backup",
"backup_id", bID)
return ms, nil, nil
}
colls, err := collectMetadata(ctx, kw, man, metadataFiles, tenantID)
if err != nil && !errors.Is(err, kopia.ErrNotFound) {
// prior metadata isn't guaranteed to exist.