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 {
|
func detailsOneDriveCmd(cmd *cobra.Command, args []string) error {
|
||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package kopia
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/go-multierror"
|
"github.com/hashicorp/go-multierror"
|
||||||
"github.com/kopia/kopia/fs"
|
"github.com/kopia/kopia/fs"
|
||||||
@ -277,6 +278,10 @@ func getItemStream(
|
|||||||
encodeElements(itemPath.PopFront().Elements()...),
|
encodeElements(itemPath.PopFront().Elements()...),
|
||||||
)
|
)
|
||||||
if err != nil {
|
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")
|
return nil, errors.Wrap(err, "getting nested object handle")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -211,26 +211,19 @@ func produceManifestsAndMetadata(
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
bup := backup.Backup{}
|
k, _ := kopia.MakeTagKV(kopia.TagBackupID)
|
||||||
|
bupID := man.Tags[k]
|
||||||
|
|
||||||
if err := sw.Get(
|
bup, err := sw.GetBackup(ctx, model.StableID(bupID))
|
||||||
ctx,
|
if err != nil {
|
||||||
model.BackupSchema,
|
|
||||||
model.StableID(man.Tags[kopia.TagBackupID]),
|
|
||||||
&bup,
|
|
||||||
); err != nil {
|
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
colls, err := collectMetadata(ctx, kw, graph.MetadataFileNames(), oc, tid, bup.SnapshotID)
|
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.
|
// prior metadata isn't guaranteed to exist.
|
||||||
// if it doesn't, we'll just have to do a
|
// if it doesn't, we'll just have to do a
|
||||||
// full backup for that data.
|
// full backup for that data.
|
||||||
if errors.Is(err, errNotRestored) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,8 +233,6 @@ func produceManifestsAndMetadata(
|
|||||||
return ms, collections, err
|
return ms, collections, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var errNotRestored = errors.New("unable to restore metadata")
|
|
||||||
|
|
||||||
func collectMetadata(
|
func collectMetadata(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
kw *kopia.Wrapper,
|
kw *kopia.Wrapper,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user