Documentation ¶
Overview ¶
Package retention implements a stateless algorithm for determining which of a sequence of backups to retain with decreasing granularity over time. It is based on the retention algorithm used by Acronis Disaster Recovery Service.
See also: https://kb.acronis.com/content/58486
Since both "backups" and "buckets" start with "b", hereafter the word "snapshots" will be used instead of "backups" for readability.
Snapshots using this method should follow a few principals: 1. Use Config.MinInterval to schedule the snapshot jobs. 2. If a previous snapshot job has not finished yet, the next one doesn't run.
Example Use:
c := retention.Config{ Hourly: 24, Daily: 6, Weekly: 4, Monthly: 11, Yearly: 1, } for range time.Tick(c.MinInterval()) { DoSnapshot() backupTimes := ListSnapshots() toDelete := retention.Delete(c, backupTimes) DeleteSnapshots(toDelete) }
Index ¶
Constants ¶
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { // Number of hourly snapshots to retain. Hourly uint // Number of daily snapshots to retain. Daily uint // Number of weekly snapshots to retain. Weekly uint // Number of monthly snapshots to retain. Monthly uint // Number of yearly snapshots to retain. Yearly uint }
Config represents the number of snapshots to retain.
func (Config) MinInterval ¶
MinInterval returns the minimum duration between snapshots. This is the interval between which backup jobs should run. If no buckets are defined, returns -1.