In addition, don't forget about ddev snapshot, which is a great and quick way to make a quick dump of your db, but it's not as portable as a text-based dump. (See ddev snapshot -h and ddev restore-snapshot -h.)
Original answer with in-container techniques:
What I always do is this:
ddev ssh
mkdir /var/www/html/.tarballs
mysqldump db | gzip >/var/www/html/.tarballs/db.sql.gz
# or with explicit authentication
mysqldump -udb -pdb -hdb db | gzip >/var/www/html/.tarballs/db.sql.gz
That places the dump in the project's .tarballs directory for later use (it's on the host).
However, I'm looking forward to the export-db command when it gets here.
Note also that starting with v1.1.0 you can use the ddev snapshot command to save a copy of a database in the .ddev/db_snapshots directory. It's not a text .sql.gz file, but it's a good saved db.
Also You could use Drupal console:
I think it's very usefull to have the TYPO3 pendant for this, thanks to Outdoorsman for the comment on GitHub Issue above.
ddev ssh and ./vendor/bin/typo3cms database:export | gzip > project_name_db.sql.gz
To explain more on @rfay answer, i generally prefer
drush cli
, however, its based on preference .As of ddev v1.4.0 (2018-11-14), there is a
ddev export-db
command. You can do these things (fromddev export-db -h
):In addition, don't forget about
ddev snapshot
, which is a great and quick way to make a quick dump of your db, but it's not as portable as a text-based dump. (Seeddev snapshot -h
andddev restore-snapshot -h
.)Original answer with in-container techniques: What I always do is this:
or for Drupal/drush users:
That places the dump in the project's .tarballs directory for later use (it's on the host).
However, I'm looking forward to the export-db command when it gets here.
Note also that starting with v1.1.0 you can use the
ddev snapshot
command to save a copy of a database in the .ddev/db_snapshots directory. It's not a text .sql.gz file, but it's a good saved db.