8.4 Retention
Retention decides which snapshots of a job are kept and which are removed. It belongs to the job or plan, not to the repository, and is applied after every successful backup and by maintenance.
The fields
Retention consists of six rules. Each field is empty or 0 (rule off) or a whole number; the form accepts values up to 9999.
Field | Effect | Default |
|---|---|---|
Last | Keeps the newest N snapshots, whatever their date. | empty |
Within days | Keeps every snapshot of the last N days. | empty |
Daily | Keeps the newest snapshot of each of the last N days. | empty |
Weekly | Keeps the newest snapshot of each of the last N calendar weeks (ISO weeks). | empty |
Monthly | Keeps the newest snapshot of each of the last N months. | empty |
Yearly | Keeps the newest snapshot of each of the last N years. | empty |
A snapshot is kept as soon as one rule keeps it; only what no rule keeps is removed. If all fields are empty, retention is off: the job keeps every snapshot forever ("every backup is kept forever") and maintenance removes nothing for it.
A line under the fields summarizes the effect, for example "Keeps last 3, 7 daily, 4 weekly, 12 monthly: oldest backup about 12 months back, at most 26 backups." The question-mark tooltip repeats the rules. Presets give a quick start:
Preset | Rules |
|---|---|
Keep all | no rule |
Last 10 | Last 10 |
30 days | Within days 30 |
GFS 7/4/12 | Last 3, Daily 7, Weekly 4, Monthly 12 |
GFS 14/8/24/5 | Last 3, Daily 14, Weekly 8, Monthly 24, Yearly 5 |
GFS stands for grandfather-father-son: many recent snapshots, few old ones.
Where retention is set
In the job editor under Retention of a backup job (see chapter 06 Jobs). If the job belongs to a plan, the plan's retention applies (see chapter 07 Schedules and Plans).
For copy jobs as Retention in the target: it applies in the target repository, separately per source job, and only to the copies this copy job made (see section 8.7 Backup copies (3-2-1)).
As the default for new jobs in the automation settings (see chapter 12 Automation and Deployment).
How snapshots are selected
The snapshots of one job form a group; the rules apply to each group on its own. Two jobs in the same repository do not influence each other. Selection works in this order:
Only snapshots this server created take part. Foreign snapshots (with forged tags or times) cannot push real ones out and are ignored.
Each rule marks the snapshots it keeps. For "daily", the newest snapshot of a calendar day counts; for "weekly", the newest of a calendar week; and so on.
Whatever no rule marks is a candidate for removal.
Protected candidates stay: snapshots with an active retention hold (for example after a ransomware warning; see chapter 11 Users and Security), snapshots under S3 Object Lock or in a hardened repository, and snapshots marked "delete never". They appear in the run log as "kept (β¦)".
When snapshots are removed
When | What happens |
|---|---|
After every successful backup | The job applies its retention and reports "retention: N old snapshot(s) forgotten" in the run log. |
Maintenance job | Reapplies the retention of all backup jobs in the repository (this catches changed rules and manual runs) and the retention of copy jobs that write into this repository. Then Prune unused data cleans the storage (see section 8.8 Maintenance, checks and restore tests). |
Forgetting only removes the snapshot; storage space is freed only when prune deletes the data that is no longer referenced. Without a maintenance job the storage therefore never shrinks, and snapshots that a changed rule has released stay until the job's next backup run or a maintenance run removes them.
Example
A machine is backed up daily at 02:00, with retention Daily 7, Weekly 4, Monthly 6.
The last 7 days each have their snapshot.
In addition, the newest snapshot of each of the last 4 calendar weeks is kept, unless it already lies within the 7 days.
In addition, the newest snapshot of each of the last 6 months is kept.
A snapshot from 8 months ago falls under no rule and is forgotten on the next run.
At most 7 + 4 + 6 = 17 snapshots remain, in practice fewer, because rules overlap: the snapshot of the first of the month is often also the newest of its week.
Retention and locks
For repositories with Object Lock or Hardened, retention must be longer than the lock, otherwise forgetting keeps running into locked snapshots. The server checks this on saving, using the largest of the periods from Within days, Daily (days), Weekly (weeks times 7), Monthly (months times 30) and Yearly (years times 365):
The lock must be shorter than this period.
Last alone is not time-based and is refused (message: "'Last' alone is not time-based: add a rule that keeps snapshots longer than N days").
Keep all (no rule) is allowed.
The job editor shows a note under the fields when the retention falls short of the lock; the repository editor lists the affected jobs and refuses to save (see section 8.3 Storage types and section 8.5 Hardened repositories).