Reuse base snapshots (#1831)
## Description During BackupCollections, use the base snapshots that were passed in from the BackupOp in the kopia uploader instead of fetching our own set of base snapshots. This will ensure the set of base snapshots is consistent throughout the backup. ## 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 - [x] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Test - [ ] 💻 CI/Deployment - [ ] 🐹 Trivial/Minor ## Issue(s) * #1740 ## Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
7a5a8c077e
commit
af15eb032c
@ -110,8 +110,6 @@ func (w *Wrapper) Close(ctx context.Context) error {
|
|||||||
// from as well as any incomplete snapshot checkpoints that may contain more
|
// from as well as any incomplete snapshot checkpoints that may contain more
|
||||||
// recent data than the base snapshot. The absence of previousSnapshots causes a
|
// recent data than the base snapshot. The absence of previousSnapshots causes a
|
||||||
// complete backup of all data.
|
// complete backup of all data.
|
||||||
//
|
|
||||||
// TODO(ashmrtn): Use previousSnapshots parameter.
|
|
||||||
func (w Wrapper) BackupCollections(
|
func (w Wrapper) BackupCollections(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
previousSnapshots []*ManifestEntry,
|
previousSnapshots []*ManifestEntry,
|
||||||
@ -136,12 +134,21 @@ func (w Wrapper) BackupCollections(
|
|||||||
deets: &details.Details{},
|
deets: &details.Details{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(ashmrtn): Pass previousSnapshots here to enable building the directory
|
||||||
|
// hierarchy with them.
|
||||||
dirTree, err := inflateDirTree(ctx, w.c, nil, collections, progress)
|
dirTree, err := inflateDirTree(ctx, w.c, nil, collections, progress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, errors.Wrap(err, "building kopia directories")
|
return nil, nil, errors.Wrap(err, "building kopia directories")
|
||||||
}
|
}
|
||||||
|
|
||||||
s, err := w.makeSnapshotWithRoot(ctx, dirTree, oc, progress, tags)
|
s, err := w.makeSnapshotWithRoot(
|
||||||
|
ctx,
|
||||||
|
previousSnapshots,
|
||||||
|
dirTree,
|
||||||
|
oc,
|
||||||
|
tags,
|
||||||
|
progress,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
@ -151,15 +158,15 @@ func (w Wrapper) BackupCollections(
|
|||||||
|
|
||||||
func (w Wrapper) makeSnapshotWithRoot(
|
func (w Wrapper) makeSnapshotWithRoot(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
|
prevSnapEntries []*ManifestEntry,
|
||||||
root fs.Directory,
|
root fs.Directory,
|
||||||
oc *OwnersCats,
|
oc *OwnersCats,
|
||||||
progress *corsoProgress,
|
|
||||||
addlTags map[string]string,
|
addlTags map[string]string,
|
||||||
|
progress *corsoProgress,
|
||||||
) (*BackupStats, error) {
|
) (*BackupStats, error) {
|
||||||
var (
|
var (
|
||||||
man *snapshot.Manifest
|
man *snapshot.Manifest
|
||||||
prevSnapEntries = fetchPrevSnapshotManifests(ctx, w.c, oc, nil)
|
bc = &stats.ByteCounter{}
|
||||||
bc = &stats.ByteCounter{}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
prevSnaps := make([]*snapshot.Manifest, 0, len(prevSnapEntries))
|
prevSnaps := make([]*snapshot.Manifest, 0, len(prevSnapEntries))
|
||||||
|
|||||||
@ -262,11 +262,13 @@ func (suite *KopiaIntegrationSuite) TestBackupCollections() {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prevSnaps := []*ManifestEntry{}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.T().Run(test.name, func(t *testing.T) {
|
||||||
stats, deets, err := suite.w.BackupCollections(
|
stats, deets, err := suite.w.BackupCollections(
|
||||||
suite.ctx,
|
suite.ctx,
|
||||||
nil,
|
prevSnaps,
|
||||||
collections,
|
collections,
|
||||||
path.ExchangeService,
|
path.ExchangeService,
|
||||||
oc,
|
oc,
|
||||||
@ -295,6 +297,19 @@ func (suite *KopiaIntegrationSuite) TestBackupCollections() {
|
|||||||
expectedTags,
|
expectedTags,
|
||||||
stats.SnapshotID,
|
stats.SnapshotID,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
snap, err := snapshot.LoadSnapshot(
|
||||||
|
suite.ctx,
|
||||||
|
suite.w.c,
|
||||||
|
manifest.ID(stats.SnapshotID),
|
||||||
|
)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
prevSnaps = append(prevSnaps, &ManifestEntry{
|
||||||
|
// Will need to fill out reason if/when we use this test with
|
||||||
|
// incrementals.
|
||||||
|
Manifest: snap,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user