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)
|
||||
// [1] https://github.com/kopia/kopia/blob/05e729a7858a6e86cb48ba29fb53cb6045efce2b/cli/command_snapshot_create.go#L169
|
||||
userTagPrefix = "tag:"
|
||||
|
||||
// Tag key applied to checkpoints (but not completed snapshots) in kopia.
|
||||
checkpointTagKey = "checkpoint"
|
||||
)
|
||||
|
||||
type Reason struct {
|
||||
|
||||
@ -192,6 +192,24 @@ func (w Wrapper) makeSnapshotWithRoot(
|
||||
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(
|
||||
ctx,
|
||||
w.c,
|
||||
@ -228,6 +246,7 @@ func (w Wrapper) makeSnapshotWithRoot(
|
||||
u := snapshotfs.NewUploader(rw)
|
||||
progress.UploadProgress = u.Progress
|
||||
u.Progress = progress
|
||||
u.CheckpointLabels = checkpointTags
|
||||
|
||||
man, err = u.Upload(innerCtx, root, policyTree, si, prevSnaps...)
|
||||
if err != nil {
|
||||
@ -236,17 +255,7 @@ func (w Wrapper) makeSnapshotWithRoot(
|
||||
return err
|
||||
}
|
||||
|
||||
man.Tags = map[string]string{}
|
||||
|
||||
for k, v := range addlTags {
|
||||
mk, mv := makeTagKV(k)
|
||||
|
||||
if len(v) == 0 {
|
||||
v = mv
|
||||
}
|
||||
|
||||
man.Tags[mk] = v
|
||||
}
|
||||
man.Tags = tags
|
||||
|
||||
if _, err := snapshot.SaveSnapshot(innerCtx, rw, man); err != nil {
|
||||
err = errors.Wrap(err, "saving snapshot")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user