One of Drupal’s more interesting abilities is the “Multi-site” installation. Drupal allows you to run multiple, separate websites with different users and different content, all on one single installation of Drupal. At first, this sounds exciting, because it has the potential to simplify site maintenance and updates. You only have to install a module once, and share it across all of your sites, etc… Like everything else in the web development world, this method has its proponents and its detractors. I’m not going to discuss the pros and cons of Drupal’s multi-site installation right now. However, I’ve recently decided to switch AutoRemarketing.com from a multi-site to a stand alone.
AR.com is the biggest site I’ve ever worked with. It’s a trade publication for the Used Car industry. It gets updated with new content several times a day, and it gets, on average, 130,000 page views every month. I inherited the site, and it had been set up initially as a multi-site, along with several other sites. So, trying to move the installation, without breaking anything, and without interrupting traffic would be challenging to say the least.
In the end, I was able to move everything over, with no loss of functionality, although I did have to take the site down for about 10 minutes. Here’s the procedure that I followed. First & foremost, I made backups of absolutely everything, then I made sure that I had multiple copies of the backups (I’m a little paranoid!). I also made sure to install drush, the Drupal shell. You can read more about drush at their site, but let me just say that it’s an amazing tool, and it’s utterly indispensable for serious Drupal work.
Once I had everything backed up and ensured that Drush was installed, my next step was to create drush aliases for everything. I simply added the following code to ~/.drush/aliases.drushrc.php:
1 2 3 4 5 6 7 8 9 10 11 12
<?php $aliases['ar_dev'] = array( 'uri' => 'ar.sacherokeedev.com', 'root' => '/var/www/html/ar.sacherokeedev.com', 'db-url' => 'mysql://dbuser:dbpassword@localhost/database', ); $aliases['ar_prod'] = array( 'uri' => 'autoremarketing.com', 'root' => '/var/www/html/drupal_media', 'db-url' => 'mysql://dbuser:dbpassword@localhost/database', );
I then used drush’s rsync capabilities to copy everything from the multi-site to the new location with this simple command:
drush rsync @ar_prod @ar_dev
The one gotcha in this case, is that drush rsyncs the entire directory, which means that you get a complete copy including all of the multi-site files. There’s probably a way to tell drush to only sync certain files, but I just copied everything then deleted what I didn’t need. The next thing to worry about is that multi-site & standalone installations use different file paths, so images won’t show up, until you run the following MySQL commands (either via phpMyAdmin or command line or your MySQL tool of choice:
UPDATE files SET filepath = REPLACE(filepath, 'autoremarketing', 'default') WHERE filepath LIKE '%autoremarketing%';
UPDATE boxes SET body = REPLACE(body, 'autoremarketing.com', 'default') WHERE body LIKE '%sites/autoremarketing.com%';
The first command changes the file path for all of the files in your database, the second changes the path to any images that are contained in Drupal blocks. That’s essentially it, but I also ran the following drush commands just to make sure:
Finally, I had to log back into the site as admin, and reset the favicon and logo paths at admin/build/themes/settings. Once that was done, all is well, and I now have a stand alone installation instead of a multi-site.