Skip to content

Backup & Restore

Neemias's main database runs on Cloudflare D1, which provides platform-managed automatic backups. D1 takes point-in-time snapshots that let you restore the database to any moment within the configured retention window. These backups are fully managed — no manual intervention or extra cron jobs required.

The backup policy is formalized in ADR-0010, which sets the snapshot frequency and retention. D1 keeps automatic daily backups and maintains weekly copies for long-term recovery. In the event of a failure or corruption, the database can be restored to the exact state of any snapshot within the retention period, directly from the Cloudflare dashboard or via API.

For scenarios that require a manual export — such as migrating between environments, an external audit, or an offline backup — the Wrangler CLI offers the wrangler d1 export command. It produces a complete SQL file with the database schema and data, which can be versioned, shared, or stored as an additional backup:

bash
wrangler d1 export neemias-db --output backup.sql

Restoring from a SQL file is done with the wrangler d1 execute command, which applies the dump directly to the target database:

bash
wrangler d1 execute neemias-db --file=backup.sql

Note that restoring via execute --file is a destructive operation: the SQL file's contents run against the database's current state. Run this procedure only in development or staging environments, or after confirming the production database is intact (with a prior snapshot). For production restores, prefer the point-in-time recovery mechanism in the Cloudflare dashboard, which is atomic and reversible.

D1's automated backup covers only the Worker's database. Data stored in the frontend's IndexedDB (offline mode) is ephemeral and syncs to the server as soon as connectivity is restored — so the D1 backup is sufficient to guarantee the application's complete data integrity.

⚠️ Section under expansion.


Source: ADR-0010wrangler d1 docs

Distributed under MIT License.