Main menu

Updating Drupal

Submitted by johng on 30 January, 2012 - 17:31
A regular maintenance task for a Drupal website is to update the core files.  This document describes the update procedure for a minor revision update, e.g. from Drupal 7.10 to 7.12. Prerequisites for this procedure include: (i) a familiarity with the command line, (ii) ssh connectivity to the target drupal website and (iii) the availability of existing backups of the website (including the drupal database)

Directory structure

The instructions assume the following directory structure:
 
www → public_html
public_html → source_html/drupal-version_num   (e.g. drupal-7.10)
 
Advantages of this type of directory structure include:
  • Multiple versions of the Drupal website can be placed in the source_html directory for testing. For larger websites there may be constraints in disk space which introduces limitations to the number of multiple versions available.
  • One can change the symbolic link to point to a different version of Drupal. In the case of an unsuccessful upgrade care needs to be taken in reverting to an earlier version if content has been added since the upgrade. A recovery of the Drupal database is required in addition to changing the symbolic link.

Procedure

Backup the Drupal website AND database before proceeding. A restore test is also essential. In the event that the upgrade doesn't work it will be necessary to restore the website from available backups. In my case, reverting to an earlier version of Drupal is simply a case of changing the public_html symbolic link to point to the earlier version of Drupal, as described in the directory structure (above). Recovering the database may also be required. 

  1. Log into the Drupal website
  2. Mark the site to Maintenance mode
    • Go to Configuration / Development
    • Select "Maintenance mode"Tick “
    • Put site into maintenance mode” and save the configuration
  3. Go to http://drupal.org/download and extract the latest version of Drupal to the target working directory on the website. The tar file is usually named drupal-7.x.tar.gz (where x denotes the version number)
  4. Extract the latest version of Drupal to the target directory (i.e. to source_html/tarfiles) and move the extracted directory to source_html/drupal-7.x (e.g. source_html/drupal-7.12)
  5. Change the symlink so that public_html points to the new Drupal installation (e.g. public_html → source_html/drupal-7.12)
  6. Delete the sites directory in the new Drupal installation and replace with the sites directory from the previous Drupal installation (e.g. source_html/drupal-7.10)
    • rm -r source_html/drupal-7.12/sites
    • cp -rp source_html/drupal-7.10/sites source_html/drupal-7.12
  7. Edit the file sites/default/settings.php to make the following change:
    • $update_free_access = TRUE;
  8. Clear the browser cache and enter the URL of the Drupal website that has just been upgraded. Append the URL with /update.php (e.g. www.johngiovannis.com/update.php)
  9. Click on the Update button
  10. Return the site from maintenance mode to normal operation

At this point the website should now be upgraded. Double check that the website functionality has not been broken. Optionally check the version of the Core modules in the Modules section. Finally edit the file sites/default/settings.php to restore the $update_free_access variable to FALSE.