Updating Modules via Drush

Drupal Version

If you have to perform module updates on your Drupal site, then Drush is the way to go. Drush will help you to update all modules on your site(s) quickly and painlessly.

Prerequisites

  • SSH/shell access
  • Somewhat higher than basic Unix/Linux command-line experience

Process

Drush has many commands and options. These commands need to be run from the directory where the settings.php file for your site is, i.e.

/path/to/drupal/sites/default

/path/to/drupal/sites/gpburdell.gatech.edu

For the purpose of updating your modules you will basically use it like below:

drush update

This is interactive and will give you a listing of all the modules that need to be updated for a given site. You can then choose to update them all or continue.  Unless you are certain you want to do all of your updates at once, I suggest you use this command to see what updates are needed, then use the below command to update a few of the modules separately at one time. For short you can also use use "drush up".

drush update modulename0 modulename1

This let's you specify a list of modules you want to update.

drush updatedb

This command will perform any updates to the database schema for your modules.  This is run automatically after every Drush update. For short you can also use "drush updb".

If you have multi-sites then after you do a Drush update you may have to move to your other multi-site folder to do a drush updatedb to update any changes to the database schema.

Best Practices

  • Limit the number of modules you use on your Drupal sites as much as possible.
  • Try to keep modules that are shared by more than one multi-site in the sites/all/modules folder.
  • Always check the release notes for any new modules to see if installing them will require any other changes or dependencies.

Gotchas

  • Drush expects a backup directory to be present in the root of your Drupal installation like /path/to/drupal/backup where it backs up the previous version of the module to.  Make sure you have write access to this directory.
  • If you had any modified files in the previous module directory you will need to copy those back to the correct place after the module is updated.  Luckily everything will be in the backup directory.
  • Depending on permissions you may need to run Drush as the super user.  Ask your system administrator for sudo access if needed.