// CONTENTS Part 08 · Data

// PART 08

Restore drill and retention

Chapter 36 / 60 2 min read English Part 08 of 15

A backup is a hypothesis until it has been restored. The drill is the executable proof, and retention is what keeps the evidence affordable.

The restore drill

scripts/restore_drill.sh takes a real dump, restores it into a throwaway database and asserts the copy before anyone is asked to trust it. Run it monthly, before a release, and after any migration that touches a tenant-scoped table.

# 1. Offline proof that the assertions themselves work — no server needed.
scripts/restore_drill.sh --self-test

# 2. Dump the source, restore into gb_restore_drill_<pid>, assert, drop it.
scripts/restore_drill.sh --dsn "$DATABASE_URL" --report /tmp/gb-restore-drill.md

# 3. Rehearse a dump you already have (uses <dump>.manifest.json when present).
scripts/restore_drill.sh --dsn "$DATABASE_URL" --dump /opt/gbo/data/backup/botserver.dump

# 4. Assert on a database that was restored by hand, without another restore.
scripts/restore_drill.sh --dsn "$RESTORED_URL" --verify-only

# 5. Keep the throwaway database and the dump for forensics.
scripts/restore_drill.sh --dsn "$DATABASE_URL" --keep

The drill asserts, on the restored copy:

  • the core tables (organizations, branches, bots, users) exist and __diesel_schema_migrations is non-empty — a restore that lost the schema or the migration history fails;
  • every table has exactly the row count recorded in the source manifest — a short or missing table names itself in the failure;
  • every generated tenant probe returns zero rows: for each table carrying org_id, branch_id, bot_id or tenant_id, rows that point at another organization, branch or bot are counted, and one non-zero probe fails the drill.

Exit codes: 0 pass, 1 mismatch (the restored copy is not trustworthy), 2 a tool or input is missing. The Markdown report written by --report is the evidence to attach to the incident or the release. The same drill runs unattended in CI: the data-integrity job in .github/workflows/ci.yml loads a deterministic dataset, runs the Rust integrity suite, then the drill.

Retention windows the platform enforces

Data Window Knob
Operational request counters (ops_request_metrics) 30 days by middleware; pruning to 7 days is safe and does not touch product data SQL delete (disk runbook)
Run events configurable retention GB_RUN_EVENTS_RETENTION_DAYS
Drive trash hourly purge job GB_TRASH_PURGE_SECS
Computer-use terminal audit 90 days (#1645) GB_TERMINAL_AUDIT_PURGE_SECS
Vibe publish ledger TTL GB_PUBLISH_LEDGER_TTL_DAYS
Vibe stale runs age threshold GB_STALE_RUN_MINUTES

Backup retention policy (operator-owned)

Backup type Retention Storage
Daily 30 days local + remote
Weekly 12 weeks remote
Monthly 12 months remote (cold)
Restore drill reports 12 months attached to release/incident records

The cleanup script deletes only what it names — verify the glob before adding it to cron, and keep at least one drill report per release train as evidence that the retention you claim is the retention you tested.

Found a mistake? Open an issue · All books

// SEARCH ESC
Pagefind · 236 pages · 4 books Enter to open ↑ ↓ to move