Upgrading from Drupal 6 to Drupal 7

I'm finally getting around to upgrading sites from Drupal 6 to Drupal 7.  Drupal 8 is coming out soon and, when that happens, Drupal 6 will fall from support.  These are my own notes for how to get the job done, but maybe they'll help others. 

I generated these notes when updating this site.  (It has been reborn as a Drupal-7 site!)  This is not my first D-7 site, but it's the first that I've upgraded from D-6 to D-7...

See the post, written so long ago, on Upgrading Drupal 5 to Drupal 6.  Many of the concepts are the same.


Read the Drupal page on the upgrade process.
Read the Drupal UPGRADE.txt file.

Ensure all modules (and themes) are available for Drupal 7. 
Custom modules have to be migrated.  See the Drupal Module conversion guide.
Similarly, any custom themes have to be migrated.  See the Drupal Theme conversion guide.

Simple sites can be updated directly.  It's probably a good idea to convert more complicated sites using a cloned site and then move the cloned site content back.  I would do this with my 'druaplSiteCopy.sh' script.

Note: there is the Drush site-upgrade command.  I couldn't get it to work.  Not a big deal -- upgrading without it is easy enough.

Also Note: that all the instructions below assume that you use my drupal deployment conventions.  Namely, the shell variable 'DRUPAL_INSTALL_ROOT' points to the directory which holds all a site's Drupal installations.  And the aliases 'ddrush' and 'dmysql' will run drush/mysql against a particular site.

Update Core:

In each of these steps, "<sitename>" is to be replaced by the site's name.  E.g. "toddgee.com"

0. Update the site fully

$ ddrush <sitename> up

1. Back the site up and store a copy of that backup away someplace safe

$ drupalBackup.sh <sitename>
$ tar czf <sitename>-backup.tar.gz <sitename>

2. Take site offline:

$ drupalDBQuery.sh setoffline <sitename>

3. Disable all contrib modules

$ dmysql <sitename>

mysql> update system set status = 0 where type = 'module' and filename like 'sites/<sitename>/modules/%';

4. Move the site to the Garland theme and disable all contrib themes.

$ dmysql <sitename>

mysql> update system set status = 0 where type = 'theme' and filename like 'sites/<sitename>/modules/%';

5. Remove the default settings file

$ rm "$DRUPAL_INSTALL_ROOT/<sitename>/sites/default/default.settings.php"

6. Remove all files from the Drupal install root except for the 'sites' directory

$ cd "${DRUPAL_INSTALL_ROOT}/<sitename>"
$ for item in * .htaccess; do if [ "${item}" != "sites" ]; then chmod -R 0777 "${item}"; /bin/rm -rf ${item}; fi; done

7. Install new version of Drupal

$ drush dl drupal --drupal-project-rename=drupal.hold --destination="${DRUPAL_INSTALL_ROOT}"
$ cp -R "${DRUPAL_INSTALL_ROOT}"/drupal.hold/* "${DRUPAL_INSTALL_ROOT}"/drupal.hold/.htaccess "${DRUPAL_INSTALL_ROOT}"/drupal.hold/.gitignore "${DRUPAL_INSTALL_ROOT}/<sitename>"
$ rm -rf "${DRUPAL_INSTALL_ROOT}/drupal.hold"

8. Update site permissions

$ drupalSetPerms.sh <sitename>

9. Make site settings.php file writable

$ chmod 0666 "${DRUPAL_INSTALL_ROOT}/<sitename>/sites/<sitename>/settings.php"

10. Turn off the update access check.

$ drupalSetAccessCheck.sh false <sitename>

11. Hit the site's update script.  Ensure the access check is turned off first (and turn it back on afterwards).

hit -> http://<sitename>/update.php

This will prompt you to begin the upgrade process.

12. Turn the update access check back on

$ drupalSetAccessCheck.sh true <sitename>

At this point, you should be able to hit your site and see it operating without any contributed modules.

Update Contrib Modules

Now we can update all the modules that were installed on the previous version.

I would have thought that 'drush pm-update' would have detected the out-of-date versions and updated them, but it didn't.  I was able to get around this by manually downloading all new versions and then running a database update.

1. Re-download all modules

Note, this will fully replace the module with the updated version.  If you made any manual modifications to the module code, they will be lost.  Make sure you preserve them!

$ dmd <sitename>
$ cd contrib
$ for module in *; do ddrush <sitename> dl ${module}; done

This will prompt you to update each module.  However, in the case that there is not a release version, it will prompt you to select your desired dev version.

2. Update all modules

$ ddrush <sitename> updatedb

This should run the update process on all modules.  After this, your sites should mostly be back to normal.

Other Stuff I Found


The CKEditor module didn't automatically enable itself for content types.  I had to go to the CKEditor configuration page ('/admin/config/content/ckeditor') and edit whatever profile I wanted to be in use and enable it for content types. 

I also had to load the ckeditor library.  This is really easy:

$ drupalManageLibraries.sh install ckeditor <sitename>


Free Tag: