mirror of
https://github.com/garethgeorge/backrest.git
synced 2025-12-13 09:15:39 +00:00
fix: downgrade omission of 'instance' field from an error to a warning
This commit is contained in:
@@ -98,7 +98,11 @@ func (r *RepoOrchestrator) SnapshotsForPlan(ctx context.Context, plan *v1.Plan)
|
|||||||
ctx, flush := forwardResticLogs(ctx)
|
ctx, flush := forwardResticLogs(ctx)
|
||||||
defer flush()
|
defer flush()
|
||||||
|
|
||||||
snapshots, err := r.repo.Snapshots(ctx, restic.WithFlags("--tag", TagForPlan(plan.Id)+","+TagForInstance(r.config.Instance)))
|
tags := []string{TagForPlan(plan.Id)}
|
||||||
|
if r.config.Instance != "" {
|
||||||
|
tags = append(tags, TagForInstance(r.config.Instance))
|
||||||
|
}
|
||||||
|
snapshots, err := r.repo.Snapshots(ctx, restic.WithFlags("--tag", strings.Join(tags, ",")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("get snapshots for plan %q: %w", plan.Id, err)
|
return nil, fmt.Errorf("get snapshots for plan %q: %w", plan.Id, err)
|
||||||
}
|
}
|
||||||
@@ -132,8 +136,13 @@ func (r *RepoOrchestrator) Backup(ctx context.Context, plan *v1.Plan, progressCa
|
|||||||
opts = append(opts, restic.WithFlags(
|
opts = append(opts, restic.WithFlags(
|
||||||
"--exclude-caches",
|
"--exclude-caches",
|
||||||
"--tag", TagForPlan(plan.Id),
|
"--tag", TagForPlan(plan.Id),
|
||||||
"--tag", TagForInstance(r.config.Instance)),
|
))
|
||||||
)
|
|
||||||
|
if r.config.Instance != "" {
|
||||||
|
opts = append(opts, restic.WithFlags("--tag", TagForInstance(r.config.Instance)))
|
||||||
|
} else {
|
||||||
|
zap.L().Warn("Creating a backup without an 'instance' tag as no value is set in the config. In a future backrest release this will be an error.")
|
||||||
|
}
|
||||||
|
|
||||||
for _, exclude := range plan.Excludes {
|
for _, exclude := range plan.Excludes {
|
||||||
opts = append(opts, restic.WithFlags("--exclude", exclude))
|
opts = append(opts, restic.WithFlags("--exclude", exclude))
|
||||||
@@ -193,10 +202,6 @@ func (r *RepoOrchestrator) Forget(ctx context.Context, plan *v1.Plan, tags []str
|
|||||||
return nil, fmt.Errorf("plan %q has no retention policy", plan.Id)
|
return nil, fmt.Errorf("plan %q has no retention policy", plan.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.config.Instance == "" {
|
|
||||||
return nil, errors.New("instance is a required field in the backrest config")
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := r.repo.Forget(
|
result, err := r.repo.Forget(
|
||||||
ctx, protoutil.RetentionPolicyFromProto(plan.Retention),
|
ctx, protoutil.RetentionPolicyFromProto(plan.Retention),
|
||||||
restic.WithFlags("--tag", strings.Join(tags, ",")),
|
restic.WithFlags("--tag", strings.Join(tags, ",")),
|
||||||
|
|||||||
Reference in New Issue
Block a user