Skip to main content

Importing a Drupal 7 site into the Aegir platform

Today I had the pleasure of launching a new Drupal 7 website into the Aegir hosting platform. However, I quickly discovered that migrating a Drupal 6 site and a Drupal 7 site, while similar, are really quite different.

The beginning

The website we were moving was built on a standard Drupal 7 installation on our development server. So the modules and themes were stored in the "sites/all/" directory and the files were stored in the "sites/default/files" directory. After getting the new website created in the Aegir system, we transferred the "sites" directory to the production server along the a dump of the database. Next, we moved the modules into our sites modules folder within Aegir ("/var/aegir/platforms/drupal7.12/sites/"). Then we moved our themes into our sites folder within Aegir ("/var/aegir/platforms/drupal7.12/"). Lastly, we moved the files directory into the Aegir system ("/var/aegir/platforms/drupal7.12/").

After changing all the permissions and reverifying the site with Aegin we discovered....

The problem

The verify task failed with with a PHP Fatal error while trying to include a module's include file. This didn't make sense because the module existed and was on the server. After inspecting the log files we discovered that the path to the missing file was incorrect.

The solution

Our development site was being developed in a subfolder within our htdocs folder. We were also storing all module/theme files with the sites/all/ directory. When we migrated our modules/themes into the new Aegir platform, the modules/themes were placed in the sites/ directory. After doings some digging, we discovered that Drupal 7 maintains a cache of all the files within the registry database table. We quickly ran the following MySQL command to replace the broken paths and the PHP fatal error subsided:

  1. UPDATE registry SET filename = REPLACE(filename, 'sites/all/', 'sites/');

Other steps.

Replace the file paths with the following queries:

block_custom table

  1. update block_custom SET body = REPLACE(body, 'sites/default/files/', 'sites/');

field_body_data table

  1. update field_data_body SET body_value = REPLACE(body_value, 'sites/default/files/', 'sites/');

field_revision_body table

  1. update field_revision_body SET body_value = REPLACE(body_value, 'sites/default/files/', 'sites/');