Updating Drupal using Drush

Submitted by admin on Sat, 05/06/2017 - 00:00

Updating Drupal using Drush

 

2 October 2016

The standard procedure to update Drupal to the latest release is to download it from drupal.org and follow the included UPGRADE.txt.

For administrators using a shell it's much easier to use Drush (Drupal Shell) instead.

Backup everything (as instructed in UPGRADE.txt)

Drush backs up the Drupal core installation for you, but you might want to back-up the sites directory just in case something goes wrong. You can use Drush to back-up the database too.

Put your site in maintenance mode

 

drush vset --exact maintenance_mode 1 drush cache-clear all

In Drupal 8, use the following.

 

drush sset system.maintenance_mode 1 drush cr

Update Drupal with drush

 

drush pm-update drupal

 

In Drupal 8, run the following from your site's root directory.

composer update drush pm-update drupal

Drush will also update your database if necessary.

Check that everything works

Go around your site and test everything! If you had modified robots.txt or .htaccess, make sure the modifications are reapplied. (Sometimes you can just copy the old files back.) If you used a custom installation profile, you might have to copy that back too. If the configuration file has changed, make sure your file has the latest and correct information - compare sites/default/settings.php and sites/default/default.settings.php.

Put your site online again

 

drush vset --exact maintenance_mode 0 drush cache-clear all

In Drupal 8, use the following.

 

drush sset system.maintenance_mode 0 drush cr

Other options

drush pm-update is the same as running drush pm-updatecode and then drush updatedb, so you can optionally run the latter two commands to break up the process.

drush pm-updatecode has a number of options you can use with drush pm-update, including --security-only. Learn more here. You can run update commands with -n to prevent it from automatically answering 'y' to every 'y/n' request for user input.