Skip to main content

Module backup_bundle_sweeper

Module backup_bundle_sweeper 

Source
Expand description

Background pruning of expired + terminal backup bundles.

Two passes on each invocation:

  1. TTL pass — for every non-terminal bundle whose expires_at has passed, delete its blob file (if any) and transition the record to Expired. The expired record persists for the retention window so audit tools and the operator-facing CLI can still see what happened.

  2. Retention pass — for every terminal bundle (Aborted, Expired, ExportAcked, ImportCommitted, ExportDownloaded) older than the retention cutoff, remove the record entirely. Default retention is 24h from created_at — long enough for operator audit follow-up, short enough that records don’t accumulate.

Called from the storage thread’s interval loop in server::run(). Failures log at warn! but don’t abort the loop — a transient fjall or filesystem error shouldn’t take down the storage thread.

Structs§

SweepStats
Sweeper result counters. Returned for the storage thread’s log line and consumed by tests asserting the right work happened.

Constants§

RETENTION_DURATION_HOURS
How long a terminal bundle’s record sticks around before the retention pass deletes it. Long enough for operator audit follow-up, short enough to keep the keyspace tidy.

Functions§

is_terminal
is_terminal already lives on BundleState but we re-export the predicate signature here as pub indirection so future callers can write backup_bundle_sweeper::is_terminal(state) without reaching into the store module’s surface. Currently referenced only by the sweeper itself + tests.
sweep_bundles
Run one sweep pass over the backup-bundle keyspace.