Drush 4 : Automated Drupal Site Database Backups made easy

Submitted by Janak on Mon, 01/10/2011 - 15:47

Following the release of Drush 4 and picking up on a couple of suggestions made by Moshe Weitzman and Nick Thompson on my previous Drush 3 Automated backup post, it was time for a revised post.

Drush 4 makes it really REALLY easy to backup all your sites, no more bash scripting etc.

Install / Update to Drush 4

Follow Drush installation guide

drushrc.php Setup

In the Drupal root directory add drushrc.php with the following setup:

 * Customize this associative array with your own tables. This is the list of
 * tables whose *data* is skipped by the 'sql-dump' and 'sql-sync' commands when
 * a structure-tables-key is provided. You may add new tables to the existing
 * array or add a new element.
$options['structure-tables'] = array(
  'common' => array(

You may need to adjust the structure-tables array to suit your requirements.

Test Drush

drush --root=/var/www/html/drupal @sites st -y

If you see the status output, proceed to the next step.

Drush Backup Command

 drush --root=/var/www/html/drupal @sites sql-dump --result-file --gzip --structure-tables-key=common

This puts the the backups in timestamp named directories within ~/.drush-backups folder.


For the automated nightly backups, you can setup the cron jobs with the above mentioned command.