Factor out function to retrieve backup details (#1894)
## Description Given a backup ID pull the backup details for the backup. This function will also be used during incremental backups as the backup details from the base snapshot(s) will need merged with the details generated by backing up new/changed items. ## Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No ## Type of change - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Test - [ ] 💻 CI/Deployment - [x] 🐹 Trivial/Minor ## Issue(s) * #1800 ## Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [ ] ⚡ Unit test - [x] 💚 E2E
This commit is contained in:
parent
5243dddcbf
commit
f37ee2b942
38
src/internal/operations/common.go
Normal file
38
src/internal/operations/common.go
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package operations
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
|
"github.com/alcionai/corso/src/internal/kopia"
|
||||||
|
"github.com/alcionai/corso/src/internal/model"
|
||||||
|
"github.com/alcionai/corso/src/internal/streamstore"
|
||||||
|
"github.com/alcionai/corso/src/pkg/backup"
|
||||||
|
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||||
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
|
"github.com/alcionai/corso/src/pkg/store"
|
||||||
|
)
|
||||||
|
|
||||||
|
func getBackupAndDetailsFromID(
|
||||||
|
ctx context.Context,
|
||||||
|
tenant string,
|
||||||
|
backupID model.StableID,
|
||||||
|
service path.ServiceType,
|
||||||
|
ms *store.Wrapper,
|
||||||
|
kw *kopia.Wrapper,
|
||||||
|
) (*backup.Backup, *details.Details, error) {
|
||||||
|
dID, bup, err := ms.GetDetailsIDFromBackupID(ctx, backupID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, errors.Wrap(err, "getting backup details ID")
|
||||||
|
}
|
||||||
|
|
||||||
|
deets, err := streamstore.
|
||||||
|
New(kw, tenant, service).
|
||||||
|
ReadBackupDetails(ctx, dID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, errors.Wrap(err, "getting backup details data")
|
||||||
|
}
|
||||||
|
|
||||||
|
return bup, deets, nil
|
||||||
|
}
|
||||||
@ -18,7 +18,6 @@ import (
|
|||||||
"github.com/alcionai/corso/src/internal/model"
|
"github.com/alcionai/corso/src/internal/model"
|
||||||
"github.com/alcionai/corso/src/internal/observe"
|
"github.com/alcionai/corso/src/internal/observe"
|
||||||
"github.com/alcionai/corso/src/internal/stats"
|
"github.com/alcionai/corso/src/internal/stats"
|
||||||
"github.com/alcionai/corso/src/internal/streamstore"
|
|
||||||
"github.com/alcionai/corso/src/pkg/account"
|
"github.com/alcionai/corso/src/pkg/account"
|
||||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||||
"github.com/alcionai/corso/src/pkg/control"
|
"github.com/alcionai/corso/src/pkg/control"
|
||||||
@ -118,21 +117,16 @@ func (op *RestoreOperation) Run(ctx context.Context) (restoreDetails *details.De
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
dID, bup, err := op.store.GetDetailsIDFromBackupID(ctx, op.BackupID)
|
bup, deets, err := getBackupAndDetailsFromID(
|
||||||
if err != nil {
|
ctx,
|
||||||
err = errors.Wrap(err, "getting backup details ID for restore")
|
|
||||||
opStats.readErr = err
|
|
||||||
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
deets, err := streamstore.New(
|
|
||||||
op.kopia,
|
|
||||||
op.account.ID(),
|
op.account.ID(),
|
||||||
|
op.BackupID,
|
||||||
op.Selectors.PathService(),
|
op.Selectors.PathService(),
|
||||||
).ReadBackupDetails(ctx, dID)
|
op.store,
|
||||||
|
op.kopia,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errors.Wrap(err, "getting backup details data for restore")
|
err = errors.Wrap(err, "restore")
|
||||||
opStats.readErr = err
|
opStats.readErr = err
|
||||||
|
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user