Add per-job backup retention
This commit is contained in:
@@ -58,7 +58,19 @@ func (r *Runner) Backup(ctx context.Context, repo model.Repository, job model.Jo
|
||||
}
|
||||
|
||||
func (r *Runner) Forget(ctx context.Context, repo model.Repository, job model.Job) error {
|
||||
args := []string{"forget", "--tag", "job:" + job.ID, "--keep-daily", fmt.Sprint(job.Retention.Daily), "--keep-weekly", fmt.Sprint(job.Retention.Weekly), "--keep-monthly", fmt.Sprint(job.Retention.Monthly)}
|
||||
args := []string{"forget", "--tag", "job:" + job.ID}
|
||||
if job.Retention.KeepWithinDays > 0 {
|
||||
args = append(args, "--keep-within", fmt.Sprintf("%dd", job.Retention.KeepWithinDays))
|
||||
}
|
||||
if job.Retention.Daily > 0 {
|
||||
args = append(args, "--keep-daily", fmt.Sprint(job.Retention.Daily))
|
||||
}
|
||||
if job.Retention.Weekly > 0 {
|
||||
args = append(args, "--keep-weekly", fmt.Sprint(job.Retention.Weekly))
|
||||
}
|
||||
if job.Retention.Monthly > 0 {
|
||||
args = append(args, "--keep-monthly", fmt.Sprint(job.Retention.Monthly))
|
||||
}
|
||||
return r.run(ctx, repo, args, nil, nil)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user