Monday, January 27, 2014

Drupal - Using Drush to update Drupal core

Drupal does not allow us to upgrade Drupal core using the admin interface the way Wordpress does. We have to manually do it ourself. I meant, backup, download the drupal-core source file, copy the new files and folders exclude the "sites" directory into the old drupal root path. Quite a lot of work.

Luckily, a genius ( :D) has created a tool name DRUSH to do the management stuffs including upgrade drupal core, modules...completely in command line. The core developers of drush has published the source code of drush in github:

"Drush is a command-line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those who spend their working hours hacking away at the command prompt."

This morning, I've just upgrade my drupal site to the latest drupal core (7.26)  by running the following drush command:

$ cd /path/to/drupal/site
$ drush pm-update drupal-7.26

The output is something like:

Update information last refreshed: Mon, 01/27/2014 - 03:42

Update status information on all installed and enabled Drupal projects:
 Name                Installed version  Proposed version  Status                                   
 Drupal core         7.24               7.26              Specified version available              
 jQuery Update       7.x-2.3            7.x-2.3           Up to date                               
 Libraries API       7.x-2.1            7.x-2.1           Up to date                               
 Superfish           7.x-1.9            7.x-1.9           Up to date                               
 Bootstrap Business  7.x-1.0            7.x-1.0           Up to date                               

Code updates will be made to drupal core.
WARNING:  Updating core will discard any modifications made to Drupal core files, most noteworthy among these are .htaccess and robots.txt.  If you have made any modifi
cations to these files, please back them up before updating so that you can re-create your modifications in the updated version of the file.
Note: Updating core can potentially break your site. It is NOT recommended to update production sites without prior testing.

Do you really want to continue? (y/n): y
Project drupal was updated successfully. Installed version is now 7.26.
Backups were saved into the directory /root/drush-backups/bt/20140127014312/drupal.                                                                          [ok]
Finished performing updates.                                                                                                                                 [ok]
The following updates are pending:

system module : 
  7079 -   Convert the 'filesize' column in {file_managed} to a bigint. 

node module : 
  7014 -   Add an index on {node}.language. 

taxonomy module : 
  7011 -   Drop unpublished nodes from the index. 

Do you wish to run all pending updates? (y/n): y

In addition, before running the update, you can check the available updates, run this command:

$ drush up -n | grep available