correct backup tag key, metadata not found (#1830)
## Description Fixes two bugs: 1. building the correc tag key when retrieving the prior backup id from a manifest. 2. returning ErrNotFound when a snapshot entry isn't found for restore. This can occur for metadata if the service has a prior backup that does not contain the expected metadata files. ## Does this PR need a docs update or release note? - [x] ⛔ No ## Type of change - [x] 🐛 Bugfix ## Issue(s) * #1823 ## Test Plan - [x] 💪 Manual
This commit is contained in:
parent
10770667ec
commit
8d09612b81
@ -334,7 +334,7 @@ func oneDriveDetailsCmd() *cobra.Command {
|
||||
}
|
||||
}
|
||||
|
||||
// lists the history of backup operations
|
||||
// prints the item details for a given backup
|
||||
func detailsOneDriveCmd(cmd *cobra.Command, args []string) error {
|
||||
ctx := cmd.Context()
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ package kopia
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/kopia/kopia/fs"
|
||||
@ -277,6 +278,10 @@ func getItemStream(
|
||||
encodeElements(itemPath.PopFront().Elements()...),
|
||||
)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "entry not found") {
|
||||
err = errors.Wrap(ErrNotFound, err.Error())
|
||||
}
|
||||
|
||||
return nil, errors.Wrap(err, "getting nested object handle")
|
||||
}
|
||||
|
||||
|
||||
@ -211,26 +211,19 @@ func produceManifestsAndMetadata(
|
||||
continue
|
||||
}
|
||||
|
||||
bup := backup.Backup{}
|
||||
k, _ := kopia.MakeTagKV(kopia.TagBackupID)
|
||||
bupID := man.Tags[k]
|
||||
|
||||
if err := sw.Get(
|
||||
ctx,
|
||||
model.BackupSchema,
|
||||
model.StableID(man.Tags[kopia.TagBackupID]),
|
||||
&bup,
|
||||
); err != nil {
|
||||
bup, err := sw.GetBackup(ctx, model.StableID(bupID))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
colls, err := collectMetadata(ctx, kw, graph.MetadataFileNames(), oc, tid, bup.SnapshotID)
|
||||
if err != nil {
|
||||
if err != nil && !errors.Is(err, kopia.ErrNotFound) {
|
||||
// prior metadata isn't guaranteed to exist.
|
||||
// if it doesn't, we'll just have to do a
|
||||
// full backup for that data.
|
||||
if errors.Is(err, errNotRestored) {
|
||||
continue
|
||||
}
|
||||
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
@ -240,8 +233,6 @@ func produceManifestsAndMetadata(
|
||||
return ms, collections, err
|
||||
}
|
||||
|
||||
var errNotRestored = errors.New("unable to restore metadata")
|
||||
|
||||
func collectMetadata(
|
||||
ctx context.Context,
|
||||
kw *kopia.Wrapper,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user