1 min read

How to import and export a database with DDEV

I use DDEV for local development when working with Drupal sites. It's VERY easy to use.

Here are a couple tips for importing and exporting databases when working locally.

The DDEV help docs are more thorough, you should go read those.

Import a gzipped database into a DDEV project

Here's a quick way to unzip a gzipped database and automatically import it as your ddev project's main database:

gzcat ~/path/to/file/database_file.gz.sql | ddev import-db

I use this the most when I've downloaded a database from a live or public test site and need to replicate that specific environment locally.

Here's a real-world example:

gzcat ~/Downloads/jason_env-1_2024-07-23T02-11-53_UTC_database.sql.gz | dd import-db

Export a gzipped database from your local DDEV container

ddev export-db -f ~/path/to-where/you-want/the-file/site_db.sql.gz

Again, check the ddev docs if you need more options. These are the two features I use the most often when dealing with databases.