Updating core, modules and database using Drush

Ready for review -- AWAITING PEER REVIEW
Description: 
Learn to update using Drush
Overview: 

We have seen most of the basic features of Drush. It is now time to learn about how to update our core, our modules and database using Drush. Follow along with these steps and remember to use 'drush help' if you are stuck.

Steps: 

1) 'pm-update' command is used to display available update information for Drupal core and all enabled projects and allow updating to latest recommended releases. It can also apply any database updates.

Open you command prompt and navigate to your site's directory. Now here, use the command

drush up

The above command updates modules and core as well as would run update.php. Read more about it here.

2) If you want to update only modules and core, use the following command:

drush upc

This command won't do the work of updatedb command i.e. it won't run update.php

upc is equivalent for pm-updatecode. Read more about it here

3) If you want to apply any database updates, type in:

drush updb

updb is equivalent to updatedb. Read more about it here.

In nutshell:
The 'drush up' command updates modules, core, and runs update.php
The 'drush upc' command updates modules only, and does not run update.php
The 'drush updb' command updates database only i.e runs update.php only.

Different possible cases:

  • If you want to see the list of modules for which update is available, use
  • drush up -n | grep available

    NOTE: 'drush up' will apply updates to everything. Use the above code to see the list of modules for which update is available and apply update one by one.

  • If you want to update particular project, use
  • drush up [PROJECT NAMES]

    So if you only want to update Drupal core, you may try:

    drush up drupal

To update your live site:

1. First backup up data using archive-dump
2. Take your site offline, using variable-set. Use the below code:

drush vset --exact maintenance_mode 1

3. Now use update commands to update your projects.
4. Now you can test your site
5. Put your site online using variable-delete as follows:

drush vdel -y --exact maintenance_mode

6. Test again and that's it!