Migrating a Community Media Drupal site off of Pantheon

The following documentation is the result of work Openflows did for Phillycam (http://www.phillycam.org), we’d like to thank Phillycam for explicitly requesting that the end result of the work be publicly posted documentation for others in a similar position to use.

Pantheon is a popular host for Drupal websites but while there are many tutorials availalbe online for how to migrate a site *to* Pantheon, when I went looking for information on how to get a client’s site *off* Pantheon I was unable to find anything.

Migrating any site away from Pantheon is difficult, migrating a site away from pantheon that also uses an Install Profile/Distribution (and migrating that to a non-Install Profile based site) is really confusing.

So, having chased down dozens of very strange issues, here is how I finally got it to work.

Note that this is very specific to the CM Drupal install profile but should apply to any distribution/profile.

The first step, of course, is to get your new server setup. I’m going to assume that you or someone you know has the skills to get that done. I’m assuming that we’re starting from a working linux server and that you have root or sudo or can otherwise log in via the command line and move things around and edit files. I’m also assuming that you have drush installed on the server.

Once you’re ready, download your Pantheon site; files and database backups. Upload those to your new server, in your home directory or another place where you can expand and look at the contents — not the directory that will be your new site.

Setup the site directory with a stock version of drupal (download the appropriate version from Drupal.org).

DO NOT use the configuration files included with your Pantheon backup. Start from the default and add in your db and other settings (memory limit for php, etc.).

In the case of the CM Drupal profile, if you are also using CiviCRM you need to download the correct version (the one you are currently using on Pantheon) and put that into place in sites/all/modules/contrib or sites/all/modules or wherever you usually store such things.

For CiviCRM you can find the default settings file at civicrm/templates/CRM/common/civicrm.settings.php.template . Copy that to sites/default/civicrm.settings.php and edit it so it’s correct (database access information, file paths, etc.)

Now the really annoying part comes in. In your Pantheon backup, you likely have modules installed in many directories.
profiles/cm_starterkit_(simple|moderate|difficult)/modules/contrib/
profiles/cm_starterkit_(simple|moderate|difficult)/modules/contrib-cm
sites/all/modules
sites/all/modules/contrib
sites/all/modules/contrib-cm
sites/all/modules/patched
sites/all/modules/custom

You need to consolidate all the modules — but only the correct, currently running version — into sites/all/modules/* in your new site directory.

Look over the list of modules currently enabled on your Pantheon hosted site and one by one move them into the correct place.

For my use, I moved modules into the following directories

sites/all/modules/contrib
sites/all/modules/contrib-cm
sites/all/modules/patched
sites/all/modules/custom

Because of how installation profiles work in Drupal, you can have the same module (and different versions of the same module) in multiple places. It is critical that you get the right ones. First look in sites/all/modules and sites/all/modules/* if the module is there, move that one. If it is not, then look in the profile directory.

This can take hours to sort, pay attention, any mistake here and things will break later. Trust me, *any* mistake here is going to bite you in the ass.

Next, move your files backup directory to sites/default/files

Then, move your theme into place in sites/all/themes/

You also need to make sure that the libraries directory at sites/all/libraries has all the libraries that are installed in the pantheon site at sites/all/libraries as well as in the libraries directory of the install profile.

You then have to delete the CiviCRM templates directory (this will be recreated automatically later)

rm -r sites/default/files/civicrm/templates_c

Now we’re ready to insert your database backup into the database that you have setup and for which you put the correct access information into the drupal and civi settings files.

Before trying to access the site via a browser it is critical that you do the following manually in the sql console:

TRUNCATE cache;
TRUNCATE cache_bootstrap;
TRUNCATE cache_path;
UPDATE `system` SET status=1 WHERE filename LIKE ‘profiles/standard/standard.profile’;

Then exit mysql and from within your site directory use drush to rebuild the registry and clear all caches (this assumes you have the drush registry_rebuild module installed).

drush rr

and

drush cc all

then

drush civicrm-update-cfg

You should now be able to log into your site (there might be issues that look funny but don’t worry yet).

If you are using the Full Calendar module, you have to update the settings at

/admin/config/user-interface/fullcalendar

to point to sites/all/libraries/fullcalendar/fullcalendar (or wherever you have placed it, as it will be pointing to the profiles directory)

After logging in go to:

/admin/config/media/file-system

and set your temp directory to the right place (usually /tmp)

Go to the following urls and make sure that the drush command for updating civicrm config settings worked for all the values in these forms

/civicrm/admin/setting/path
/civicrm/admin/setting/url
/civicrm/admin/setting/updateConfigBackend
/civicrm/menu/rebuild?reset=1&triggerRebuild=1

You should now have a working site.

Note that there are some directories that Pantheon does not add to your backup, this can cause problems but the only solution is to get the site to generate those files again. In the case of the site I was working on we had to go into the configuration screen for CSS Injector and edit/save all the overrides to get them to regenerate and for the site to look right.

Good luck.