feat(storage): periodic backup scheduler with rotation - #57
Merged
Conversation
- Store.ScheduleBackups(dir, interval, keep, maxAge) returns a BackupScheduler writing timestamped VACUUM INTO snapshots with unique nano suffixes (VACUUM INTO refuses existing targets) - Start runs the loop: immediate first snapshot, then per-interval best-effort snapshots; each tick rotates the directory via RotateBackups - Stop drains the run loop; Stop without Start and repeated Start/Stop are safe no-ops - Tests: validation, RunNow+rotation with restore-readback, start/stop lifecycle, stop-without-start (race-clean)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 2 follow-up to #51/#55.
Problem: backups existed but nothing schedules them — hosts had to hand-roll timers.
Solution:
Store.ScheduleBackups(dir, interval, keep, maxAge)returns aBackupScheduler:RunNow(ctx)takes one timestampedVACUUM INTOsnapshot + rotates (nano-suffix names avoid same-second collisions)Start()runs the loop: one immediate snapshot (short-lived hosts still leave a backup), then per-interval best-effort snapshots, each tick pruning viaRotateBackupsStop()drains the run loop; Stop-without-Start and double Start/Stop are safe no-opsNo interface changes. Race-clean tests cover validation, run-now+rotation with restore readback, lifecycle, and stop-without-start; full suite green.