Skip to content

Commit 44a669c

Browse files
lifecycle manager automatically retains the best Logical backup and the best Physical backup for every single week and month in the schedule
1 parent db352b1 commit 44a669c

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

pbm/lifecycle/manager.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,25 +129,31 @@ func Evaluate(cfg config.LifecycleConf, backups []backup.BackupMeta, dryRun bool
129129
continue
130130
}
131131

132+
// Weekly Retention Bucket
132133
if cfg.WeeklyRetention > 0 && !bcpTime.Before(weeklyCutoff) {
133134
if isCalendar {
134135
year, week := bcpTime.ISOWeek()
135-
weekKey := fmt.Sprintf("calendar-week-%d-W%02d", year, week)
136+
// Append the backup Type to the bucket key
137+
weekKey := fmt.Sprintf("calendar-week-%d-W%02d-%s", year, week, bcp.Type)
136138
weeklyCandidates[weekKey] = append(weeklyCandidates[weekKey], bcp)
137139
} else {
138140
weekBucket := ageInDays / 7
139-
weekKey := fmt.Sprintf("rolling-week-%d", weekBucket)
141+
// Append the backup Type to the bucket key
142+
weekKey := fmt.Sprintf("rolling-week-%d-%s", weekBucket, bcp.Type)
140143
weeklyCandidates[weekKey] = append(weeklyCandidates[weekKey], bcp)
141144
}
142145
}
143146

147+
// Monthly Retention Bucket
144148
if cfg.MonthlyRetention > 0 && !bcpTime.Before(monthlyCutoff) {
145149
if isCalendar {
146-
monthKey := bcpTime.Format("2006-01")
150+
// Append the backup Type to the bucket key
151+
monthKey := fmt.Sprintf("%s-%s", bcpTime.Format("2006-01"), bcp.Type)
147152
monthlyCandidates[monthKey] = append(monthlyCandidates[monthKey], bcp)
148153
} else {
149154
monthBucket := ageInDays / 30
150-
monthKey := fmt.Sprintf("rolling-month-%d", monthBucket)
155+
// Append the backup Type to the bucket key
156+
monthKey := fmt.Sprintf("rolling-month-%d-%s", monthBucket, bcp.Type)
151157
monthlyCandidates[monthKey] = append(monthlyCandidates[monthKey], bcp)
152158
}
153159
}

0 commit comments

Comments
 (0)