Free ops runbook · Cloudflare D1/R2

D1 and R2 recovery: restore the database, not just the backup

A bad migration or a bulk delete is not fixed by a backup file you never restored. D1 has time travel and bookmarks; R2 has object versioning. The drill is to restore into a new place, verify the rows and objects, then decide on the cutover.

D1 time travel

A rolling window of restore points; a bookmark pins the exact state to return to.

Exports are not backups

d1 export gives you a snapshot file; you still need a restore path.

R2 versioning

Object versioning keeps old objects; lifecycle rules can delete them earlier than you think.

Restore to the side

Bring the copy up next to production, verify, then switch. Never test on the only copy.

Detect

Know your restore points

CommandWhat it shows
npx wrangler d1 time-travel info <DB>The current bookmark and the restore window.
npx wrangler d1 export <DB> --output=snapshot.sqlA logical snapshot for verification.
npx wrangler r2 object get <bucket>/<key>Whether the object still exists and which version.
R2 lifecycle rulesHow long non-current versions survive.
Drill

Restore checklist

Pick a known-good point

Before the bad write; record the bookmark and the timestamp.

Restore to a scratch DB

Verify row counts and a few business invariants, not just "it imported".

Check objects

A database row can point at an R2 object that is gone; check both sides.

Cut over with a plan

Freeze writes, switch, verify, then re-enable. Keep the old copy until the next day.

Keep going

This page is free. The paid runbooks cover the operational failures around it, with detection commands, five failure modes and a migration checklist.