Skip to content

feat(storage): backup rotation with count/age retention - #55

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

feat(storage): backup rotation with count/age retention#55
Patel230 merged 1 commit into
mainfrom
feat/storage-backup-rotation

Conversation

@Patel230

Copy link
Copy Markdown
Contributor

Phase 2 follow-up to #51.

Problem: repeated Backup calls accumulate unbounded snapshot files; nothing prunes them.

Solution: Store.RotateBackups(ctx, dir, keep, maxAge)

  • Keeps the newest keep backups (0 = unlimited count), deletes the rest
  • Additionally prunes any remaining backup older than maxAge (0 = unlimited age)
  • Guarantees the newest backup is never removed by age, so an idle store never ends up with zero backups
  • Also sweeps stale .tmp files left by interrupted Backup writes (older than 24h)

No interface changes, additive only. 7 unit tests + end-to-end Backup+rotate cycle; full suite green.

- Store.RotateBackups(dir, keep, maxAge): keep newest N, prune
  maxAge-exceeded backups, never delete the newest backup by age alone
  so an idle store never ends up with zero backups
- Sweeps stale *.tmp files from interrupted Backup operations (24h)
- Works with timestamped names; ordering is mtime-based
- Tests: count/age retention, newest-protection, no-limit pass-through,
  tmp sweeping, empty/invalid dir handling, and end-to-end Backup+rotate
@Patel230
Patel230 merged commit 97412b9 into main Aug 15, 2026
12 checks passed
@Patel230
Patel230 deleted the feat/storage-backup-rotation branch August 15, 2026 11:24
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