Skip to content

feat(storage): periodic backup scheduler with rotation - #57

Merged
Patel230 merged 1 commit into
mainfrom
feat/storage-backup-scheduler
Aug 15, 2026
Merged

feat(storage): periodic backup scheduler with rotation#57
Patel230 merged 1 commit into
mainfrom
feat/storage-backup-scheduler

Conversation

@Patel230

Copy link
Copy Markdown
Contributor

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 a BackupScheduler:

  • RunNow(ctx) takes one timestamped VACUUM INTO snapshot + 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 via RotateBackups
  • Stop() drains the run loop; Stop-without-Start and double Start/Stop are safe no-ops
  • Validation rejects non-positive intervals and negative retention

No interface changes. Race-clean tests cover validation, run-now+rotation with restore readback, lifecycle, and stop-without-start; full suite green.

- 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)
@Patel230
Patel230 merged commit b6e81a0 into main Aug 15, 2026
12 checks passed
@Patel230
Patel230 deleted the feat/storage-backup-scheduler branch August 15, 2026 13:01
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.

1 participant