Skip to content

feat: manage backup retention in Klio instead of Kopia - #238

Open
gabriele-wolfox wants to merge 2 commits into
mainfrom
dev/168
Open

feat: manage backup retention in Klio instead of Kopia#238
gabriele-wolfox wants to merge 2 commits into
mainfrom
dev/168

Conversation

@gabriele-wolfox

@gabriele-wolfox gabriele-wolfox commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Replace Kopia's snapshot-expire retention with a retention policy manager that Klio owns: Klio evaluates its own backup catalog and deletes the expired backups, rather than delegating to kopia snapshot expire.

Highlights

  • New retentionPolicy in the PluginConfiguration with a single latest criterion (keep the N most recent backups), configurable per tier and validated to be at least 1. Omitting it keeps every backup.
  • The tier2 snapshot pins are removed. The invariant that a tier1 backup is never deleted before it reaches tier2 now lives in the retention selection, read from our own catalog, so snapshot manifest IDs stay stable.
  • Retention travels to the server on the CloseBackup request and is applied per tier by the backup consumer after every backup.
  • New klio retention apply command (and ApplyRetention gRPC call) to apply the configured retention on demand (eg. without waiting for the next backup, to reclaim space quickly after tightening the policy).
  • The old klio retention set/get CLI and the Kopia retention-policy plumbing are removed.

Testing

The tier2 retention e2e now exercises both automatic retention (three backups, keep two, verify the oldest is deleted) and the on-demand command (tighten to one, run klio retention apply, verify only the
newest remains).

Closes #168.

@gabriele-wolfox
gabriele-wolfox force-pushed the dev/168 branch 3 times, most recently from ec38630 to 5972f01 Compare September 7, 2026 15:35
Replace Kopia's snapshot-expire retention with a Klio-managed policy
manager that evaluates the backup catalog and deletes the expired
backups itself. The only criterion for now is latest, which keeps the N
most recent backups; it is configured per tier in the PluginConfiguration
and must be at least 1.

Because retention no longer runs through Kopia, the tier2 snapshot pins
are gone. The invariant that a tier1 backup is never deleted before it
reaches tier2 now lives in the retention selection, read from our own
catalog, which keeps snapshot manifest IDs stable.

The tier1 and tier2 policies travel to the server on the CloseBackup
request, and the consumer applies them per tier after every backup. The
klio retention CLI and the Kopia policy plumbing are removed.

Assisted-by: Claude

Signed-off-by: Gabriele Quaresima <gabriele.quaresima@enterprisedb.com>
Add a klio retention apply command and an ApplyRetention gRPC call that
apply the configured retention immediately, without waiting for the next
backup. This frees space on demand, for example after shrinking the
policy on a nearly-full disk.

The command reads the client configuration and sends the tier1 and tier2
policies to the server, which enqueues a maintenance-only task. The
backup consumer then runs the same per-tier retention path used after a
backup, so there is a single retention implementation.

Assisted-by: Claude

Signed-off-by: Gabriele Quaresima <gabriele.quaresima@enterprisedb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Retention policies are not atomic across a backup's snapshots

1 participant