Categories
Uncategorized

Can you clone Drupal sites?

I was asked the following question today and this is my stab at a response. I’d appreciate and welcome any feedback if you’ve worked with a Drupal multi-site instance.

Can you clone sites? Or would you have to clone every part of a site and reassemble it for each site?

It depends on what you have to clone, but it tends to be more cloning parts of a site (encapsulated in modules and themes, in Drupal parlance) than cloning entire sites outright.

If you mean to easily add, update features and presentation, the way to go about it is through modules, themes+subthemes, and use of code versioning (I like subversion).

My assumption is that each sub site will be its own drupal instance. Drupal lets you share modules across themes through the use of its /sites directory, particularly /sites/all, anything in that folder is available to all sites. Updating modules/themes in that folder would make the updated code available on all sub sites once they run Drupal’s update command. For a more detailed explanation, see Setup of /sites directory for multi-site

That takes care of moving functionality and some theming changes. Its much trickier to move layout changes, although its possible. To do so, you can forego using some of Drupal’s configuration options (for example, to position blocks). Instead, alter the layout via themeing hooks done in PHP code. This makes it easy to store and track changes with code versioning, this is where subversion (svn) comes in. This means that layout changes affecting how blocks of content appear on the site, more often than not, have to be done my an experienced drupal developer but it saves you from manually having to make these changes via Drupal’s admin interface on every site that you manage.

I would say that using SVN has been the key to making this process mostly painless for me. It is easy to move changes through testing > staging > production environments. The ‘svn update’ command does the work and knows what file-level changes need to be made, including adding/removing files. Coupled with Drupal’s built-in update functions available in modules, and you have a predictable way to propagate changes.

.

I didn’t touch upon moving actual content from one site to another, since that requires a wholly different approach.