updating a drupal site

Revised on Wednesday, 24 August 2011 - to improve update speed.

For updating a Drupal 6 site with Cpanel and phpMyAdmin,, such as from 6.20 to 6.22.

Original Drupal instructions are in: http://drupal.org/upgrade/ and the upgrade.txt file of the drupal core. Those instructions take precedence, so use these instructions at your own risk. They do work well on my particular version of Cpanel and phpMyAdmin.

Multisite/multidomain: if you use these you are probably an intermediate/advanced user. Note that you have multiple settings.php files.

Overview

Make fresh backups of the code and the database. Go to the status report and download the new drupal core and module versions as shown there. Upload the new drupal core version tar.gz file to the site root where main drupal files reside. Extract it and it creates a directory DrupalX.X.

Login as user one, switch to default theme and put the site in maintenance mode.

Delete all Drupal code from the server - except, do not delete and be sure to keep the entire existing "sites" directory, the existing ".htaccess" and "robots.txt" files, and of course the newly uploaded Drupal core tar.gz file. Also keep any non-core file you or the cpanel system might have added ("cgi-bin", possibly "php.ini", fantastico, symlinks).

Go into the new dupalX.x directory that was created by the extraction. Here, delete its "sites" directory and the ".htaccess" and "robots.txt" files. Then, move the entire remaining contents of the dupalX.x directory into the root. Delete the remaining empty dupalX.x directory. Run update.php.

Now upload any new module versions. Delete the old modules and extract the new versions. Run update.php. Practically done.

Now re-enable the original theme and take the site out of maintenance mode. Done.

More or less optional, but good to do from time to time: check the new versions of settings.php, .htaccess, robots.txt for significant updates. Synchronise if needed.

Step-by-step

Prepare

Its good to stay organised. Make a working directory on your computer to contain the backup database file and the backup code file. Generally I make a new directory for every backup, so that things don't get confused:
- sitename-date-drupalversion

Make one or more working directories to contain Drupal core, modules and themes.
- Drupal6
-- drupal-core-v6.22
---- drupal-6.22-extracted
---- drupal-6.22-check
-- modules
-- themes

The "extracted" and "check" direcories are only needed if the core is extracted on local computer. This may only be necessary to optionally check 3 files (see below).

Backup

- Backup the database with Cpanel phpMyAdmin. Before backing up, it makes sense to "Clear cached data" at Site configuration > Performance (this reduces the size of the database contents and may reduce risk of mysql error 1153, for the case that you want to re-install the backup). Then export the sql database tables and save them on your computer. There is now a simplification and slight change with new Cpanel versions. Log into Cpanel, go to phpmyadmin, click on the database name, click export (on the right side). Basically you could use default Quick/minimal options, default SQL and click Go. But, better to add the date to the name of the bacup file. Click Custom, in file name add: _theactualdate. Then move to the bottom and click Go. Save the file.

- Backup the site's file system in a compressed copy with Cpanel file manager: Open Cpanel, go to file manager, select public_html, check mark select all, click compress, check mark gzipped. Choose a "save as" name such as sitename-pub-html-date-version.tar.gz. When changing file name do not use the "delete" button (it causes a file deletion), but use backspace. Click OK. Find the file in the "public_html" (if not, the "home") directory on the server. Download it to the computer and save it.

- These backups are important. Always keep the SQL file and the code base intact and together (they are a pair). Do not mess with them. You absolutely need these if something goes wrong - and it's super easy to restore things with these two files.

Download Core

- Find the update on site Home > Administer > Reports > Status report. Download the core update and save it on your computer.

Earlier here, I recommended to extract the core on local computer and perform replacement of the "sites" directory, the existing ".htaccess" and "robots.txt" there, then compress and upload the edited version. I considered this safer. Two reasons for a change, one being to eliminate the small risk of losing proper file permissions and two, doing this online is simply faster.

Prepare Update

- Login as User1 - if not, you can't update and may lose access to your site (to fix, see UPGRADE.txt #10)
- Switch to Garland theme in Site building > Themes, disable/uncheck all others
- Put the site in maintenance mode in Site configuration > Maintenance mode (get back in at site.tld/user/login)
- Turn off (not uninstall) all non-core modules (remember to turn exactly these back on later)
-- this is official instruction, yet some specialists say it's not needed to turn them off (generally I don't)
-- if turned off, best to make a web page image of the modules overview page to remember which modules are enabled.

Upload New Core

- Upload the core update tar.gz file to your site's public_html or where your main drupal files are located. Extract it. It makes a new directory DrupalX.X containing a complete new core.

Delete Files

- Go to your public_html directory, containing your original Drupal installation and delete all files - except, do not remove and keep: the "sites" directory, the ".htaccess" and "robots.txt" files. Also do not delete any non-core file you or the cpanel system might have added (like "cgi-bin", possibly "php.ini", fantastico, or symlinks). You will still be using these with and after the update.

The "sites" directory contains your module and settings data, the ".htaccess" is likely to have been automatically customised, while you may or may not have made changes to your "robots.txt" file.

- Go into the new drupal core directory that the extraction made, that is the DrupalX.X directory. In this directory delete the "sites" directory, the ".htaccess" and "robots.txt". You must remove these, so that when the new core replaces the old core, it does not overwrite any important existing information.

Move Files

- After deleting the files as mentioned above, move everything from DrupalX.X to the public_html root. Then delete the empty DrupalX.X directory. You now have a new Drupal core together with your existing important files.

Update

- Run update.php. Almost done.

Modules

- Check Administer > Reports > Status report for needed module updates. Download the needed modules to your computer through links here. Upload the module tar.gz files to where these contributed modules are located either at sites/all/modules or sites/default/modules. Do not extract them yet.
- Delete the outdated installed modules fully from the site. Then extract the replacement module versions.
- Run update.php. Almost done.

Consideration

The "settings.php" file at sites/defaut/settings.php, ".htaccess" in root and "robots.txt" in root, are using their previous versions. While the likelihood is relatively small, from time to time Drupal also updates the code for these. In that case you may wish to do a manual synchronisation between your custom content and new code. I check on this every so-and-so-many updates.

Finalise

Re-enable the original theme and take the site out of maintenance mode.
Enjoy all those check marks in the Status Report!

Comments

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h2> <h3> <div>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
Thanks for your help in stopping spam.
Fill in the blank