Drush

Common Commands

Official Drush documentation

drush help
List all drush commands. Use the format "drush help command" to show help specific to one command.
For more help, see http://www.drush.org/ or do a $ drush
drush cc all
Clear all the caches
drush rr
Repair Registries
drush ard
Backup a Site to your default location (~/drush-backups)
drush arr archiveFile options
Restore a site. Example:
drush arr ~/drush-backups/archive-dump/20140522165827/vanillaDrupal.20140522_165827.tar.gz --overwrite
IMPORTANT:
  1. Your database user must temporarily be given more privileges (I just give it god-level during the restore) than when running with the standard production level privileges.
  2. The current working directory must be up one level from the site because the site directory will be created during this process.
  3. After the restore, remember to set directory permissions. i.e. give the webserver appropriate security permissions.
drush up project
Upgrade modules and/or drupal core.
drush dl project
Downloads a module to your site.
drush en project
Enables an extension (module or theme). This is often used on conjunction with drush dl project

Reinstall a Module

If you have devel enabled, then you can use this command:

drush dre project

Otherwise, run these three commands:

drush pm-disable project

drush pm-uninstall project

drush pm-enable project

Upgrading to Newer Version of Drupal

On your local install version, do this to upgrade Drupal using Drush:

  1. Perform a Drush archival dump first. $ drush archive-dump

    Another example: $ drush ard --description="taken prior to 7.31 upgrade"

    archive-dump will copy the database and all the files. It puts it in a gzip tar ball and by default it goes to ~/drush-backups/archive-dump/

    The AZ guys replaced the stock GNU tar file with the BSD version instead because GNU wasn’t handling special characters. OS X already uses the BSD version of tar.

  2. Save a copy of the web.config file (found in the root directory of the Drupal site, and in the /tools folder of Cyfernet)
  3. Make sure module "Update Manager" is enabled. (I turn it off in Development).
  4. Run $ drush up drupal

    Prior to running the command, make sure you have write permissions and the webserver doesn’t have any locks on the files. This can be accomplished by stopping the website and then using Task Manager to kill the w3wp processes and php* process owned by the site you just shut down.

  5. Run /update.php (if Drush didn’t do the database update portion for you.)
    Note: When pulling these updates, via Mercurial/GIT, to the Production server, you will need to manually run the /update.php after doing the pull/update.
  6. Compare web.config with the copy you saved in step 2; you may have to manually tweak our copy.
  7. Test.
  8. Push to development server.
  9. Run /update.php if there were schema changes.