Quick backup of Drupal database with Drush

selwyn's picture

What a great utility Drush is.  If you don't know, it is a command-line utility for use to do all sorts of amazing things to a Drupal system.  You can easily make a quick database backup with the following command:

drush sql-dump >dbdump.sql

This will dump your entire database into the text file dbdump.sql.  Of course linux in it's minimalist way will report nothing back to you if the command succeeds so to see the resultant file, try:

ls -la db*

and you will see something like:

-rw-rw-r--  1 selwyn  selwyn  70915526 Mar 15 10:41 dbdump.sql

This means you have a file named dbdump.sql which is about 70 Megabytes long. You have to be in the folder where your Drupal site resides.  You can issue a command like

drush status

to verify that all is working ok before you issue any drush commands.  This will also verify which database your Drupal install is pointing to. btw.  The command to restore from the dbdump file is just as easy:

drush sqlc <dbdump.sql