OpsVault

Retention

Automatically delete old backup files to save disk space.

Retention policies automatically clean up old backups so your disk (and remote storage) doesn't fill up. OpsVault supports two independent rules that can be combined:

  • keep_last — keep only the N most recent backup files per database
  • keep_days — delete files older than N days

Both rules apply to local files and remote storage independently.

Configuration

retention:
  local:
    enabled: true
    keep_last: 7      # keep the 7 most recent local backups per database
    keep_days: 30     # also delete any local backup older than 30 days

  remote:
    enabled: true
    keep_last: 0      # disabled
    keep_days: 90     # delete remote backups older than 90 days

How rules interact

When both rules are set, they are applied in order:

  1. keep_days runs first — deletes files beyond the age cutoff
  2. keep_last runs second — deletes files beyond the count limit from whatever remains

This means keep_last acts as a hard cap regardless of age.

Example: keep_last: 5 and keep_days: 30

  • A file that is 20 days old but is one of the 5 most recent → kept
  • A file that is 31 days old → deleted by keep_days
  • If you have 8 files all within 30 days → the 3 oldest are deleted by keep_last

Set either value to 0 to disable that specific rule.

Local retention

retention:
  local:
    enabled: true
    keep_last: 7
    keep_days: 0      # only count-based, no age limit

Local retention scans backup_dir for files matching {database_name}_*.sql.gz and removes the ones that exceed the configured limits.

Remote retention

retention:
  remote:
    enabled: true
    keep_last: 0      # disabled
    keep_days: 60     # delete remote files older than 60 days

Remote retention uses rclone:

  • keep_daysrclone delete --min-age={N}d --include "{name}_*.sql.gz" {remote}:{path}
  • keep_lastrclone lsf to list files, then rclone deletefile for each excess file

Remote retention only runs when storage.rclone.enabled is also true.

Common configurations

Minimal — local only, keep a week:

retention:
  local:
    enabled: true
    keep_last: 7
    keep_days: 0
  remote:
    enabled: false

Local + remote with different policies:

retention:
  local:
    enabled: true
    keep_last: 7      # only keep 7 local copies
    keep_days: 0
  remote:
    enabled: true
    keep_last: 0
    keep_days: 90     # keep remote copies for 3 months

Age-based only:

retention:
  local:
    enabled: true
    keep_last: 0      # no count limit
    keep_days: 14     # delete anything older than 2 weeks
  remote:
    enabled: true
    keep_last: 0
    keep_days: 180    # 6 months on remote

On this page