Drupal - Use Drush to Export/Import a MySQL Database Dump File

Submitted by admin on Wed, 02/07/2018 - 14:47

Export Database to File

Drupal 6 and 7

drush cc

drush sql-dump > ~/my-sql-dump-file-name.sql

drush sql-dump --gzip --result-file=backupdbsite.sql

Drupal 8

drush cr

drush sql-dump > ~/my-sql-dump-file-name.sql

drush sql-dump --gzip --result-file=backupdbsite.sql

Import Database

drush sql-drop

drush sql-cli < ~/my-sql-dump-file-name.sql