How to Upgrade a Drupal6 Site to Drupal7


CSE-specific notes to upgrade a Drupal6 site to Drupal7.

Prepare the Existing Production Site to be Upgraded

Create a Development Copy of the Drupal Site

  1. Create an empty database to house the new Drupal7 site:
    mysql> create database drupal_SITENAME_7;
  2. Switch the theme to Garland, which exists across versions. The customized theme you've probably applied to your site probably won't work in the upgraded site until you've applied a lot of customization.
  3. Note custom and locally-installed modules that are enabled in Drupal6 and need to be recreated in the Drupal7 site. Determine appropriate upgrade steps for each module. This page shows modules moved into the Drupal7 core, so they don't need to be installed:
  4. Offline the production Drupal6 site to freeze the database.
  5. Dump the production Drupal6 version of the SITENAME database:
    % mysqldump -u readonly_user -p***** drupal_SITENAME > drupal_SITENAME.`date +\%Y\%m\%d`.sql
  6. Restore the SITENAME database dump to the empty SITENAME_7 database:
    % mysql -u root -p drupal_SITENAME_7 < drupal_SITENAME.20110520.sql
  7. Grant the database user privileges over the SITENAME_7 database:
    mysql> grant all on drupal_SITENAME_7.* to 'drupal_SITENAME'@'localhost';
    Query OK, 0 rows affected (0.00 sec)
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)

Recreate Admin User (UID 1) Credentials

  1. Perform admin tasks as UID 1 until you have your personal account and permissions restored. Update UID 1's password to comply with Drupal7's upgraded password hashing mechanism. Generate the password hash:
    % cd /usr/local/www/drupal7/
    drupal7% ./scripts/ 'MYPASSWORD'
    password: MYPASSWORD            hash: $S$DKQdnqSQRDxR9SIQ7f1mi6Pl3BznmOZMZBf7vRSBsx580eLT/9Gn
    [postel] drupal7%
  2. Now update UID 1's password with that password hash:
    mysql> update users set pass='$S$DKQdnqSQRDxR9SIQ7f1mi6Pl3BznmOZMZBf7vRSBsx580eLT/9Gn' where uid=1;
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 0

Prepare the Development Drupal7 Site

  1. Create the Drupal7 site directory location:
    [postel] % cd /usr/local/www/drupal7/sites/
    [postel] sites% sudo mkdir
    [postel] sites% sudo chown www
  2. Copy the default Drupal6 configuration file to the Drupal6 site directory:
    [postel] sites% cd
    [postel] sudo cp -p ../default/settings.php .
  3. Edit the configuration file's $db_url value to point to the SITENAME_6 database:
    [postel] sudo chmod 644 settings.php
    $db_url = 'mysql://USERNAME:PASSWORD@localhost/DATABASE';
    [postel] sudo chmod 444 settings.php
  4. Copy over the files directory, if it exists.
  5. Copy over any custom or local themes, if they exist.
  6. Create Site URLs for the Archive Site and the Development Site:
    % cd /wikis/root
    [postel] root% sudo ln -s /usr/local/www/drupal5 SITENAME_5
    [postel] root% sudo ln -s /usr/local/www/drupal6 SITENAME_6

Upgrade the Development Drupal6 Site

This is where the magic happens.

  1. In the settings.php configuration file, set $update_free_access = TRUE;:
  2. From the web, run the Drupal6 update.php script:
  3. Check the Status Report. Fix problems that it describes.
  4. Enable the 'Update Status' Module.
  5. Grant authorized 'User management' -> 'Permissions' to 'Access Site Reports'.
  6. In the settings.php configuration file, set $update_free_access = FALSE;
  7. chmod 444 the configuration file.
  8. Install Drupal6 versions of cusstom and locally-installed modules, perhaps including: views, token, pathauto, upload path, taxonomy access control (TAC), Securepages, Filter Default, LDAP, fasttoggle.


Preserve the Drupal5 site data

  1. Change the Drupal5 site name to have a live archive of the Drupal5 site:
    [postel] % cd /usr/local/www/drupal5/sites
    [postel] sites% sudo mv
  2. Update the database name in the configuration file, settings.php:
  3. Leave the Drupal5 SITENAME archive offline. It shouldn't be accessible to the public, but it should be available if you need to downgrade the SITENAME site.

Enable the Production Drupal6 site

  1. Dump the Drupal6 version of the site:
    [postel] backups% mysqldump -u readonly_user -p***** drupal_SITENAME_6 > drupal_SITENAME_6.`date +\%Y\%m\%d`.sql
  2. Drop the existing production database, recreate an empty version of it:
    mysql> drop database drupal_SITENAME;
    Query OK, 54 rows affected (0.01 sec)
    mysql> create database drupal_SITENAME;
    Query OK, 1 row affected (0.00 sec)
  3. Restore the development Drupal6 version of the site to the production database:
    [postel] backups% mysql -u root -p drupal_SITENAME < drupal_SITENAME_6.20110520.sql
  4. Change the Drupal6 site name:
    [postel] % cd /usr/local/www/drupal6/sites/
    [postel] sites% sudo mv
  5. Change the Drupal6 configuration file, settings.php to point to the production database.
  6. Enable the production URL to point to our Drupal6 content:
    [postel] % cd /wikis/root
    [postel] root% sudo rm SITENAME
    [postel] root% sudo ln -s /usr/local/www/drupal6/ SITENAME
    [postel] root% sudo rm SITENAME_6
  7. Online the production site.
  8. Configure LDAP settings to remove the password change field, if this site relies on LDAP authentication only (that is, if people external to UBIT can't create and manage accounts).
  9. Compare the Drupal5 and Drupal6 sites. You may need to fix some views to synchronize them.


  1. postel:/usr/local/share/doc/drupal7/UPGRADE.txt