Skip to content

Milestone 1: automatic scheduled backups, retention, and a tested restore path #8

Closed

Description

@TusanHomichi

Problem or outcome

The validated VACUUM INTO backup mechanism (#2) exists but only runs when an operator remembers to run it, nothing prunes old snapshots, and restore is undocumented manual file surgery. Milestone 1 requires automatic validated backups with a tested restore path, and ADR 0003 promised the mechanics.

Scope

In scope:

  • Automatic backups from serve: a background task takes a validated snapshot on a fixed interval (default daily), including once shortly after startup when the newest snapshot is older than the interval
  • Retention: keep the newest N snapshots (default 14), pruning only after a new snapshot validates; never prune the last remaining snapshot
  • consolebook restore <snapshot>: validates the snapshot as its own database, refuses while the server holds the database, sets aside the current database as a pre-restore snapshot, moves the validated snapshot into place, and verifies invariants and integrity afterward
  • backup command applies the same retention pruning
  • Audit events for backup and restore (the domain model lists both as audited actions)
  • doctor warns when the newest snapshot is older than the interval
  • Configuration via CLI flags / env (interval hours, retention count), consistent with existing flags
  • Integration tests: scheduling decision logic, retention pruning edge cases, full restore round-trip, refusal paths

Out of scope:

  • Off-host backup replication (operator's job via the backups/ directory)
  • In-app notices for backup failures (arrives with the notices slice, which will use this slice's outcome reporting)
  • Backup encryption (needs its own decision)

Acceptance criteria

  • A running server produces validated snapshots on schedule with no operator action
  • Retention keeps exactly the configured count and never deletes the only snapshot
  • A destroyed database is recoverable end-to-end with consolebook restore and the result passes doctor
  • Backup and restore actions appear in the audit record
  • All repository gates pass

Expected proof

  • cargo fmt --check && cargo clippy --workspace --all-targets -- -D warnings && cargo test --workspace
  • A scripted destroy-and-restore run against the real binary

Related roadmap, decisions, or issues

Activity

  1. added a commit that references this issue on Aug 28, 2026
    5ee4d8b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions