SSQZ/atlasDocs
Backup (preview)

Retention and prune Preview

Backups grow with every snapshot. forget decides which snapshots to keep, protect marks the ones that must never go, and prune reclaims the space the rest used.

Forget by rule#

sqz backup forget <repo> --keep-last N [--keep-hourly N] [--keep-daily N] [--keep-weekly N]
                  [--keep-monthly N] [--keep-yearly N] [--dry-run] [--prune]

Always try a rule with --dry-run first. It prints what would be kept and removed, and changes nothing:

sqz backup forget D:\backups\laptop --keep-last 5 --keep-daily 7 --keep-weekly 4 --keep-monthly 12 --dry-run
sqz backup forget D:\backups\laptop --keep-last 5 --keep-daily 7 --keep-weekly 4 --keep-monthly 12 --prune

Each --keep-* rule keeps the newest snapshot of each of that many periods (hours, days, weeks, months or years, in UTC). A snapshot kept by any rule stays. --prune runs prune straight after.

Forget chosen snapshots#

sqz backup forget D:\backups\laptop 3 4 7

Removes the snapshots you name (by number or ID prefix).

What is never forgotten#

sqz backup protect D:\backups\laptop 12      # never forget snapshot 12
sqz backup unprotect D:\backups\laptop 12

list shows which snapshots are protected and which is verified.

Prune#

sqz backup prune <repo> [--dry-run] [--grace HOURS] [--max-waste PERCENT]
sqz backup prune D:\backups\laptop --dry-run
sqz backup prune D:\backups\laptop

forget only removes snapshot records; the data they used stays until prune. Prune works out what the remaining snapshots still need, then:

  1. rewrites partly used packs, copying the still-needed pieces as they are, without decrypting them;
  2. writes one consolidated index;
  3. reads the new files back to check them;
  4. only then deletes the old index files, and last the old packs.

Stopping prune at any point loses nothing: the repository still checks clean apart from unused data, and the next prune finishes the job. Prune refuses to start if any snapshot, index or needed pack is unreadable, and changes nothing in that case.

Do not restore while pruning

A restore that started before prune can fail with a missing pack. It never returns wrong data, but it has to be run again.

What it saves#

In a test, a 1.2 GB repository grew to 1,432 MB over 8 more snapshots (each replacing a 32 MB file and changing 200 small ones). forget --keep-last 2 and prune brought it down to 955 MB in under 2 seconds. Prune's cost follows the data kept, not the data removed.

A sensible schedule#