Add logging for bases in incremental backups (#2151)
## Description Add log statements noting which bases were used for kopia assisted incrementals and which bases were merged into the hierarchy. Also record the reasons a base was chosen. Log statements when searching for previous snapshots will be added when that code is refactored ## 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] 🧹 Tech Debt/Cleanup ## Issue(s) * #2149 ## Test Plan - [x] 💪 Manual - [ ] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
48e4b65165
commit
f01c8ad843
@ -15,6 +15,7 @@ import (
|
|||||||
"github.com/hashicorp/go-multierror"
|
"github.com/hashicorp/go-multierror"
|
||||||
"github.com/kopia/kopia/fs"
|
"github.com/kopia/kopia/fs"
|
||||||
"github.com/kopia/kopia/fs/virtualfs"
|
"github.com/kopia/kopia/fs/virtualfs"
|
||||||
|
"github.com/kopia/kopia/repo/manifest"
|
||||||
"github.com/kopia/kopia/snapshot/snapshotfs"
|
"github.com/kopia/kopia/snapshot/snapshotfs"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
@ -884,6 +885,17 @@ func inflateDirTree(
|
|||||||
return nil, errors.Wrap(err, "inflating collection tree")
|
return nil, errors.Wrap(err, "inflating collection tree")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
baseIDs := make([]manifest.ID, 0, len(baseSnaps))
|
||||||
|
for _, snap := range baseSnaps {
|
||||||
|
baseIDs = append(baseIDs, snap.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Ctx(ctx).Infow(
|
||||||
|
"merging hierarchies from base snapshots",
|
||||||
|
"snapshot_ids",
|
||||||
|
baseIDs,
|
||||||
|
)
|
||||||
|
|
||||||
for _, snap := range baseSnaps {
|
for _, snap := range baseSnaps {
|
||||||
if err = inflateBaseTree(ctx, loader, snap, updatedPaths, roots); err != nil {
|
if err = inflateBaseTree(ctx, loader, snap, updatedPaths, roots); err != nil {
|
||||||
return nil, errors.Wrap(err, "inflating base snapshot tree(s)")
|
return nil, errors.Wrap(err, "inflating base snapshot tree(s)")
|
||||||
|
|||||||
@ -178,11 +178,20 @@ func (w Wrapper) makeSnapshotWithRoot(
|
|||||||
bc = &stats.ByteCounter{}
|
bc = &stats.ByteCounter{}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
snapIDs := make([]manifest.ID, 0, len(prevSnapEntries))
|
||||||
prevSnaps := make([]*snapshot.Manifest, 0, len(prevSnapEntries))
|
prevSnaps := make([]*snapshot.Manifest, 0, len(prevSnapEntries))
|
||||||
|
|
||||||
for _, ent := range prevSnapEntries {
|
for _, ent := range prevSnapEntries {
|
||||||
prevSnaps = append(prevSnaps, ent.Manifest)
|
prevSnaps = append(prevSnaps, ent.Manifest)
|
||||||
|
snapIDs = append(snapIDs, ent.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.Ctx(ctx).Infow(
|
||||||
|
"using snapshots for kopia-assisted incrementals",
|
||||||
|
"snapshot_ids",
|
||||||
|
snapIDs,
|
||||||
|
)
|
||||||
|
|
||||||
err := repo.WriteSession(
|
err := repo.WriteSession(
|
||||||
ctx,
|
ctx,
|
||||||
w.c,
|
w.c,
|
||||||
|
|||||||
@ -340,6 +340,8 @@ func consumeBackupDataCollections(
|
|||||||
|
|
||||||
for _, m := range mans {
|
for _, m := range mans {
|
||||||
paths := make([]*path.Builder, 0, len(m.Reasons))
|
paths := make([]*path.Builder, 0, len(m.Reasons))
|
||||||
|
services := map[string]struct{}{}
|
||||||
|
categories := map[string]struct{}{}
|
||||||
|
|
||||||
for _, reason := range m.Reasons {
|
for _, reason := range m.Reasons {
|
||||||
pb, err := builderFromReason(tenantID, reason)
|
pb, err := builderFromReason(tenantID, reason)
|
||||||
@ -348,12 +350,34 @@ func consumeBackupDataCollections(
|
|||||||
}
|
}
|
||||||
|
|
||||||
paths = append(paths, pb)
|
paths = append(paths, pb)
|
||||||
|
services[reason.Service.String()] = struct{}{}
|
||||||
|
categories[reason.Category.String()] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
bases = append(bases, kopia.IncrementalBase{
|
bases = append(bases, kopia.IncrementalBase{
|
||||||
Manifest: m.Manifest,
|
Manifest: m.Manifest,
|
||||||
SubtreePaths: paths,
|
SubtreePaths: paths,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
svcs := make([]string, 0, len(services))
|
||||||
|
for k := range services {
|
||||||
|
svcs = append(svcs, k)
|
||||||
|
}
|
||||||
|
|
||||||
|
cats := make([]string, 0, len(categories))
|
||||||
|
for k := range categories {
|
||||||
|
cats = append(cats, k)
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Ctx(ctx).Infow(
|
||||||
|
"using base for backup",
|
||||||
|
"snapshot_id",
|
||||||
|
m.ID,
|
||||||
|
"services",
|
||||||
|
svcs,
|
||||||
|
"categories",
|
||||||
|
cats,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return bu.BackupCollections(ctx, bases, cs, tags, isIncremental)
|
return bu.BackupCollections(ctx, bases, cs, tags, isIncremental)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user