Add tags to checkpoints in kopia (#2153)
## Description Tags allow searching for previous snapshots (complete or otherwise). This in turn provides the ability to use kopia-assisted incrementals in more situations as partially completed backups will be reused for their cached data. Streaming files that have not been completely uploaded are not added to a checkpoint so there is no possibility of accidentally triggering kopia-assisted incrementals thus causing us to treat a partially uploaded file in a checkpoint as a "cached" version of the complete file ## 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 - [ ] 🧹 Tech Debt/Cleanup ## Issue(s) * closes #1674 ## Test Plan - [x] 💪 Manual - [ ] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
f01c8ad843
commit
4f8f76f1eb
@ -24,6 +24,9 @@ const (
|
|||||||
// (permalinks)
|
// (permalinks)
|
||||||
// [1] https://github.com/kopia/kopia/blob/05e729a7858a6e86cb48ba29fb53cb6045efce2b/cli/command_snapshot_create.go#L169
|
// [1] https://github.com/kopia/kopia/blob/05e729a7858a6e86cb48ba29fb53cb6045efce2b/cli/command_snapshot_create.go#L169
|
||||||
userTagPrefix = "tag:"
|
userTagPrefix = "tag:"
|
||||||
|
|
||||||
|
// Tag key applied to checkpoints (but not completed snapshots) in kopia.
|
||||||
|
checkpointTagKey = "checkpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Reason struct {
|
type Reason struct {
|
||||||
|
|||||||
@ -192,6 +192,24 @@ func (w Wrapper) makeSnapshotWithRoot(
|
|||||||
snapIDs,
|
snapIDs,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
checkpointTagK, checkpointTagV := makeTagKV(checkpointTagKey)
|
||||||
|
|
||||||
|
tags := map[string]string{}
|
||||||
|
checkpointTags := map[string]string{
|
||||||
|
checkpointTagK: checkpointTagV,
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, v := range addlTags {
|
||||||
|
mk, mv := makeTagKV(k)
|
||||||
|
|
||||||
|
if len(v) == 0 {
|
||||||
|
v = mv
|
||||||
|
}
|
||||||
|
|
||||||
|
tags[mk] = v
|
||||||
|
checkpointTags[mk] = v
|
||||||
|
}
|
||||||
|
|
||||||
err := repo.WriteSession(
|
err := repo.WriteSession(
|
||||||
ctx,
|
ctx,
|
||||||
w.c,
|
w.c,
|
||||||
@ -228,6 +246,7 @@ func (w Wrapper) makeSnapshotWithRoot(
|
|||||||
u := snapshotfs.NewUploader(rw)
|
u := snapshotfs.NewUploader(rw)
|
||||||
progress.UploadProgress = u.Progress
|
progress.UploadProgress = u.Progress
|
||||||
u.Progress = progress
|
u.Progress = progress
|
||||||
|
u.CheckpointLabels = checkpointTags
|
||||||
|
|
||||||
man, err = u.Upload(innerCtx, root, policyTree, si, prevSnaps...)
|
man, err = u.Upload(innerCtx, root, policyTree, si, prevSnaps...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -236,17 +255,7 @@ func (w Wrapper) makeSnapshotWithRoot(
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
man.Tags = map[string]string{}
|
man.Tags = tags
|
||||||
|
|
||||||
for k, v := range addlTags {
|
|
||||||
mk, mv := makeTagKV(k)
|
|
||||||
|
|
||||||
if len(v) == 0 {
|
|
||||||
v = mv
|
|
||||||
}
|
|
||||||
|
|
||||||
man.Tags[mk] = v
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := snapshot.SaveSnapshot(innerCtx, rw, man); err != nil {
|
if _, err := snapshot.SaveSnapshot(innerCtx, rw, man); err != nil {
|
||||||
err = errors.Wrap(err, "saving snapshot")
|
err = errors.Wrap(err, "saving snapshot")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user