July 3, 2012 - Comments Off on Drush de Jour: Getting your backup back up

Drush de Jour: Getting your backup back up

Last week we saw a couple of quick ways to get a database backup of your Drupal site with Drush and the command line. Here is a drushy way to restore that backup.

% drush vset --yes maintenance_mode 1
% drush sqlc < sitebackup.sql

Login as admin and check that everything is ok (www.yoursite.com/user).

% drush vset --yes maintenance_mode 0

We're using drush's sqlc command which is taking the sitebackup.sql file and dumping it back into your database. If you omit the < and backup file you will be taken to the mysql (or whatever database backend) cli, logged in as the drupal site sql user.

Taking your site offline ensures no one is making changes to the database and is a nice way to let people know that the site is not broken. You can additionally specify a maintenance mode:

% drush vset --yes maintenance_mode_message "The website is currently being updated. Please check back in a few minutes"

Drush vset (variable-set) and its partner in crime, vget (variable-get), allow you to access the variables table from your site's database. Wonderful things can be done with these two commands, like putting the site into maintenance mode. You can also check your site's current theme:

% drush vget theme

And yes, vget will pull all variables that match the substring you enter. so 'vget theme' will pull the admin_themedefault_theme, etc.

The Drush de Jour brings you the latest and possibly greatest bits of drush wisdom we use for developing and maintaining our Drupal sites.

Published by: chazcheadle in The Programming Mechanism
Tags: ,

Comments are closed.