Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zachharkey/7437095 to your computer and use it in GitHub Desktop.
Save zachharkey/7437095 to your computer and use it in GitHub Desktop.
Redux of Tyler's article for my own gist-based shortcut recall purposes. http://tylerfrankenstein.com/code/use-drush-export-import-drupal-mysql-database-dump-file

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

Export Database to File

[...] Behold the power of Drush (once you are ssh'd in and navigated to your drupal root directory)

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

Those two commands clear all the Drupal caches and then dump the sql database to a file in your home directory. Awesome sauce!

Download Database (optional)

If the sql dump file is on a remote server, you can use this terminal command to download a copy of the sql file:

scp [email protected]:~/my-sql-dump-file-name.sql ~/Desktop/

Import Database

You can use this command to import the sql dump back into your drupal database.

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

A Drush-Less Approach

If you don't have Drush setup (which you should have setup if you want to be cool), you can check out this article to make a backup copy of your Drupal's MySQL database from a terminal: Drupal - How to Make a Backup Copy of MySQL Database

Redux of Tyler's article for my own gist-based shortcut recall purposes.
http://tylerfrankenstein.com/code/use-drush-export-import-drupal-mysql-database-dump-file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment