Skip to content
xaweho

Knowledge base · intermediate

Prune explained — how PBS automatically clears out old backups

Prune decides which snapshots get deleted — based on the retention policy. What it does, what it doesn't do, and why it frees no storage on its own.

intermediate ·

Prune is the process where PBS marks snapshots as “no longer needed” and deletes them — based on the retention policy. Important to understand: prune alone frees no storage. Prune only decides which snapshots should go. The storage comes back only with garbage collection (GC).

How prune decides

Prune follows the retention policy. For each snapshot it checks whether the rules say it should be kept:

  • Keep last N: the last N backups, regardless of when
  • Keep daily N: one backup per day, for the last N days
  • Keep weekly N: one backup per week, for the last N weeks
  • Keep monthly N: one backup per month, for the last N months
  • Keep yearly N: one backup per year, for the last N years

If any of these rules says a snapshot should be kept, it stays. Otherwise it gets deleted on the next prune run.

Concrete example: you have keep-daily=7, keep-weekly=4, keep-monthly=6, keep-yearly=2. With daily backups, you keep:

  • The last 7 daily backups
  • Plus 4 weekly ones (the Sunday backup each time, but only one per week)
  • Plus 6 monthly ones (the last of the month)
  • Plus 2 yearly ones (the last of the year)

That makes 7 + 3 (weeks not covered by daily) + 5 (months not covered by weekly) + 2 = ~17 snapshots per VM in total.

PBS is smart about this: snapshots that satisfy several criteria don’t get counted twice.

Where is prune configured?

Two places, with different effects:

1. In the PVE backup job

In Datacenter → Backup → Job → Retention tab you set the policy. This policy applies only to the local backup job — that is, only to the snapshots this job creates.

If you have several jobs (say for test and production VMs), you can set a separate retention per job.

2. In the PBS datastore

In Datastore → Prune & GC you set a datastore-wide policy. This applies to all snapshots in the datastore, no matter who created them.

Important: if both policies are set, the stricter one wins. PBS policy keep-daily=7 and PVE job keep-daily=14 → effectively 7 are kept.

For most private customers:

keep-last:    3
keep-daily:   7
keep-weekly:  4
keep-monthly: 6
keep-yearly:  2

That gives you a safety net for yesterday, last week, last month and last year — with minimal storage usage.

For higher compliance requirements (medical practices, law firms):

keep-last:    7
keep-daily:  30
keep-weekly: 12
keep-monthly: 24
keep-yearly:  7

That keeps 30 daily, 12 weekly, 24 monthly and 7 yearly — good for audit trails spanning several years.

Running prune

In the GUI:

  1. Open Datastore → Content.
  2. Click a VM node or the entire datastore.
  3. Prune in the action menu.
  4. Enter the retention values in the dialog, enable dry-run — you’ll see which snapshots would be deleted.
  5. Once you’re happy, disable dry-run and run it.

On the CLI:

proxmox-backup-client prune \
  vm/100 \
  --keep-daily 7 --keep-weekly 4 --keep-monthly 6 \
  --dry-run \
  --repository 12345@pbs@pbs01.xaweho.de:12345

With --dry-run you see what would happen, without anything actually getting deleted.

Protecting a snapshot from prune

If you have an important snapshot that must never be deleted:

  1. Open Datastore → Content, select the snapshot.
  2. Click the snapshot → set the Protected checkbox.

That snapshot won’t be touched by any prune run — even when retention says it should long be gone.

Useful for things like “pre-migration backup” or “backup before the PostgreSQL 17 update”.

Frequently asked questions

Why is my datastore full even though prune runs? Because prune alone frees no storage. Prune marks snapshots as deleted, but the chunk files (the actual data) stay on disk — until garbage collection runs. See garbage collection.

When does prune run automatically?

  • If you enabled it in the PVE backup job (default: yes, after every backup run).
  • If you set a schedule policy in the PBS datastore.

Can I restore a snapshot after it’s been pruned? No, not from the PBS. Once prune has run and GC after it, the chunks are gone. If the snapshot was pruned only just now and GC hasn’t run yet, we could in theory restore the snapshot entry — but we advise against it, because inconsistencies can occur.

What does “keep-last” mean? The N most recent backups, completely independent of the date. Useful for example with keep-last=3: the three latest backups always stay, even if all of them were made within the last hour. A safety net against accidental mass pruning.

Can I trigger prune manually? Yes, via Datacenter → Backup → Job → Run now, which runs backup + prune immediately. Or in PBS under Datastore → Prune & GC → Run prune.

How do I see what prune deleted? In the task log: Tasks → latest prune task → log. It lists line by line which snapshot was deleted and why.

Can I protect snapshots from prune with notes? Not automatically — notes are pure annotations. Protection from prune works exclusively through the Protected flag.

What’s next

Related products
Tags
pbs prune retention

Did this article help?

If not, open a ticket. If it did, we're happy about a referral — both sides get €25 credit on their customer account.