Friday, March 30, 2012

Migrate Drupal 6 to Drupal 7

Changing from Drupal 6 to Drupal 7 is not just a simple update. The steps seem straightforward, but there are major changes in the way Drupal 7 works and stores data. So a move up across major version numbers is really a "migration" as opposed to a simple update or patch.



If your site is fairly simple, with good backups, and you use the right approach, you can accomplish the migration without too much trouble.

The more complex your site is, the more complex the migration will be.


Doing a migration involves several steps. You might want to review these related tutorials.

Step 1: Backup your site's database


tutuploads1_9a01976bcb0177f97c97f4fdbb1ac351.png



* It is wise to try an update or upgrade on a test copy of your site before applying it to your live site. Even minor updates can cause your site's behavior to change.

There is a handy tool called Backup and Migrate, which helps simplify the backup process, which you can download from this page http://drupal.org/project/backup_migrate. Note: it only works with MySQL, and is still under development. You should also do a manual backup of your database using phpMyAdmin. We show you how to do this in this tutorial.




Step 2: Backup all your folders and files




You have several ways to do this, and you might want to do it more than one way for safety

  1. You can download all the files to your local computer

  2. Copy the files to another directory on your server

  3. Use the backup facility that is probably built into your hosting control panel


You can't be too paranoid about having extra copies.




Step 3: Double check to make sure you can complete the upgrade




Check on the Drupal 7 status of your contributed and custom modules and themes.




Step 4: Check for the latest version of Drupal 6.x


tutuploads4_78cc6a39019111ff812b3d9ebb947ab1.png



You can't skip versions when you upgrade. For instance you cant go from 6.0 to 6.2 in one step. You also can't upgrade directly from 6.0 or 6.1 to Drupal 7. You have to have your Drupal 6 installation at the latest level.

How do I know which version of Drupal I'm running?

  • Go to Administer (or Administration) >> Reports >> Status report.

  • You will see your version number if you have Drupal 6.0 or later. In Drupal 5.x and earlier, the path to go to is Administer >> Logs >> Status report.


Where do I get the latest version of Drupal 6? http://drupal.org/project/drupal




Step 5: Take the site off-line


tutuploads5._Take_the_site_off_line..png



Go to Administer >> Site configuration >> Site maintenance.




tutuploads5.png



Select "Off-line" and save the configuration.




Step 6: Change the theme to Garland


tutuploads6._Change_the_theme_to_Garland..png



Go to Administer >> Site building >>Themes




tutuploadsmedia_1312655385441.png



Click the check box to enable the theme, and the radio button to make it the default. Scroll to the bottom of the page and save changes.

You need to use the basic theme. If you are using a template, check with the designer to see if there is an updated version, and you can do that upgrade after the site is working with Garland.




Step 7: Disable all non-core modules


tutuploads6._Go_to_the_modules_page_and_disable_all_non-core_module.png



Go to Administer >> Site building >> Modules.




tutuploads7._Disable_all_modules_that_are_not_listed_under_Core_-_r.png



You can expand the categories by clicking on the category name and see what is enabled. If you added an additional modules to your site, there will be additional categories. Expand them and uncheck the boxes next to the modules




Step 8: Clear all optional module check boxes


tutuploads8._Clear_all_optional_module_check_boxes_and_save_the_cha.png



It is possible that some modules cannot be immediately disabled, because others depend on them. Repeat this step until all non-core modules are disabled and all check boxes are clear. Be sure to scroll to the bottom of the page and save the changes.




Step 9: Remove unwanted modules


tutuploads9.png



If you know that you will not re-enable some modules for Drupal 7.x and you no longer need their data, then you can uninstall them under the Uninstall tab after disabling them. The Uninstall tab is at the top of the modules page.




Step 10: Remove sites/default/default.settings.php


tutuploads10._Remove__sitesdefaultdefault.settings.png



On the command line or in your FTP client, remove the file /sites/default/default.settings.php




Step 11: Delete all your other folders and files except /sites/


tutuploads11._DO_NOT_DELETE_the_sites_folder__but_go_ahead_and_dele.png



Empty your Drupal files directory except for:

  • /sites/

  • any custom files you added elsewhere.


If you made modifications to files like .htaccess or robots.txt, you will need to record those changes and re-apply them after the new files are in place.




Step 12: Remove unwanted module folders


tutuploads12.png



If you are abandoning any modules because they are not compatible with Drupal 7, remove them from the directory
sites/all/modules




Step 13: Download and extract Drupal 7


tutuploads13._Download_and_extract_Drupal_7__then_copy_all_the_file.png



Download Drupal 7 if you haven't already. http://drupal.org/project/drupal

You can extract the files on the server and copy them to your main directory. Alternately you could extract them on your local computer and use FTP to move them to your sever.

Don't worry about overwriting the files in the sites folder. Only the files that need replacing will be replaced.




Step 14: Reapply any changes to your .htaccess file or robots.txt files


tutuploads14._Reapply_any_changes_to_your_.png



Re-apply any modifications to files such as .htaccess or robots.txt. Use a text editor to make changes.




Step 15: Make your settings file writable


tutuploads15._Make_your_settings_file_writable.png



Make your settings.php file writable, so that the update process can convert it to the format of Drupal 7.x. settings.php is usually located in sites/default/settings.php

Normally this would best be set at 444, but it needs to be writable so 644 or 666 if you are having trouble will be the correct setting. BE SURE YOU REMEMBER TO COME BACK AND RESTORE THIS SETTING AFTER YOU ARE FINISHED with the migration.




Step 16: Run update.php


tutuploads16._Run_update.png



Run update.php by visiting http://www.example.com/update.php (replace www.example.com with your domain name). This will update the core database tables. Click continue and follow the steps.



 If you can't access update.php make a change to your settings file:
tutuploads17._If_you_can_t_access_update.png



If you are unable to access update.php do the following:

- Open settings.php with a text editor.

- Find the line that says:
$update_free_access = FALSE;

- Change it into:
$update_free_access = TRUE;

- Once the upgrade is done, $update_free_access must be reverted to FALSE.




Step 17: Backup your new database


tutuploads18.png



Using the same procedure you used before, make another database backup. Save it with a different name or to a different location than your original backup. You may still need that one.




Step 18: Upgrade your modules to their newer versions.




You've gone through the core upgrade, but now each module has to be upgraded. Then you can update and re-enable your non-core modules by following these steps:

  1. Check your notes, and the UPGRADE.txt files inside each module, to see if any special upgrade instructions apply

  2. Fully remove the old module directory inside sites/all/modules/ (if you haven't already)

  3. Download, unpack and move the new module directory to sites/all/modules/

  4. Enable the module

  5. Run update.php again (you should have run it once already when upgrading core) and check for any message output.

  6. Back up your database and files again, between each module update, so that if there is a problem, you can revert to the most recent update.


If you have errors when you run the update.php script:

  1. Note any error messages you see.

  2. Restore your site to its previous state, using the file and database backups you created before you started the upgrade or update process. Do not attempt to do further updates or upgrades on a site that had update problems.





Step 19: Upload your Drupal 7 compatible theme


tutuploads20.png



Make sure everything works in the Garland theme before you switch over to your Drupal 7 theme.




Step 20: Go to Reports and run a Status report


tutuploads21.png



16. Go to Administration >> Reports >> Status report. Verify that everything is working as expected.




Step 21: Set update_free_access is set to false


tutuploads22.png



Ensure that $update_free_access is FALSE in settings.php.




tutuploadsmedia_1312661333788.png



  • Go to Administration >> Configuration >> Development >> Maintenance mode.

  • Disable the "Put site into maintenance mode" check box and save.





tutuploadsmedia_1312661436093.png



Scroll to the bottom of the page to save the configuration.

That should be the last step in your successful migration from Drupal 6 to Drupal 7.

Related Tutorials:

Planning for a Drupal 6 to Drupal 7 Migration

How To Put Drupal 7 In Maintenance Mode.

Migrating Drupal 6 CCK Data To Drupal 7 Fields



1 comment: