How to take SQL backup using Drush?

| | 1 min read

Being drush in your portfolio has something to count on you. Drush has its own way of doing things. We all might be knowing on how to make a copy of the database of a project profile using MySQL in bash.

In drush, we have drush sql-dump command,

 drush sql-dump --result-file=<backup-dir>/<project-code>_`date +%F`.sql.gz 

Using drush command we can take the back up of the database quick and smooth.

This command supports around 14 options, few of them are,

  • Result file
    --result-file : This is the path along with the file-name to which the copy has to be taken,
    if no value id specify find the backup under date folder in drush-backups in home folder.
  • Skip tables
    --skip-tables-list : This is optional. If someone don't want a copy of a particular table, just specify it this array.
  • Skip Data
    --structure-tables-list, which specifies a set of tables whose data are no more needed but its structure is.
  • Tables list
    --tables-list. Set of tables to be listed.
  • GZip the backup
    --gzip : compressing the values passed as the argument using gzip program.

While running this command, make sure you are inside a Drupal installation. The above options can come handy when we want only one table, or even only data, or else the structure as the result.

To update drush on you Drupal site, please have look over here.

Please get in touch with us to know more.