Runbook — Back up and recover the D1 database
RepoWrangler's D1 database holds inventory snapshots, sync state, sessions, and audit metadata — no provider tokens. Everything in it can be rebuilt from the providers, so the worst-case recovery is a clean re-discovery.
Back up
bash
wrangler d1 export repo-wrangler --remote --output backup-$(date +%Y%m%d).sqlStore the export privately: it contains your repository inventory and health history. Do not commit it to any repository.
Restore into a fresh database
Create the database and apply migrations:
bashwrangler d1 create repo-wrangler # update database_id in wrangler.jsonc with the new id wrangler d1 migrations apply repo-wrangler --remoteImport the backup:
bashwrangler d1 execute repo-wrangler --remote --file backup-YYYYMMDD.sqlRedeploy (
pnpm build && wrangler deploy) and checkGET /health/ready.
Recover with no usable backup
- Create the database and apply migrations as above.
- Deploy, sign in, and run Run discovery now from Administration (or wait for the next scheduled reconciliation).
- Discovery, enrichment, governance, security, and billing sync rebuild the estate over the following cycles. History (pipeline runs, closed change requests, budget snapshots) restarts from now — current-state pages are complete once enrichment finishes.
Point-in-time note
D1 also has Time Travel (wrangler d1 time-travel) for restoring a database to a recent point in time without an export — prefer it for accidental-write recovery when the incident is fresh.