Back up or export a D1 database to a .sql file

d1 & hyperdrive

// what it does

Dumps the remote database to a .sql file — full schema+data for a portable backup, or --no-data for a schema-only snapshot you can diff or use to seed a new environment. --table <name> narrows the export to specific tables.

// shell

$ wrangler d1 export <name> --remote --output ./backup.sql
$ wrangler d1 export <name> --remote --no-data --output ./schema.sql

// gotcha

--output is required; there is no stdout default. Don't confuse the two filters: --no-data emits schema only, --no-schema emits data only.