Reply to comment

Cloning a Drupal Multisite Subsite

Tagged:  

If you have a Drupal multisite configuration, you will sometimes want to clone one of your Drupal subsites so that you can use it as the basis of a new subsite. This is particularly useful when it becomes clear that you are mixing two sets of content in one Drupal subsite and want to split that content between two subsites. By cloning the existing subsite, you end up with two Drupal subsites each of which is free to develop in its own unique direction.

 

This advice applies to Drupal 6.x, on shared hosting, with a single database, and no direct server access. I works for me at One.com. If you are with a different hosting company, make sure you do some research before attempting this.

  1. Back everything up (your Drupal files and your database).
  2. Clear all the Drupal caches.
  3. Create a new subsite folder (e.g. /sites/mysite.com.mynewsubsite) on you local machine and copy the entire of contents (including hidden files) of /sites/mysite.com.myexistingsubsite) into it.
  4. Search across all files in /sites/mysite.com.mynewsubsite) and replace the "myexistingsubsite" string wherever you find it. (I do this on a local copy of the folder, using Windows Explorer's search tool for this, then I load all the found files in Notepad++ to do the Find and Replace.)
  5. In the settings.php file in the /sites/mysite.com.mynewsubsite directory make sure that the database prefix is now correct for your subsite, for example:

    $db_prefix = 'mynewsubsite_';
     

  6. Upload the whole /mysite.com.mynewsubsite directory (or whatever you have called it) to the Drupal webserver's /sites directory. You should now have a directory structure on your webserver that looks like this:

    www.mysite.com/sites/default/
    www.mysite.com/sites/mysite.com.myexistingsubsite/
    www.mysite.com/sites/mysite.com.mynewsubsite/

  7. Using a simple text editor like Notepad, create a text file called makesymlink.php containing this text:

    <?php
    symlink(".", "newsubsite");
    print "Done";
    ?>

  8. Upload makesymlink.php to the root directory of your webserver.
  9. Run makesymlink.php by going to http://www.mysite.com/makesymlink.php in your browser. The script will run and "Done" should be displayed in your browser.
  10. Delete makesymlink.php from your webserver.
  11. Using Drupal's Backup and Migrate module, take a backup of your database in uncompressed form, and download it to your local machine.
  12. Open the backup file and search for the statements that begin with your existing subsite's prefix.
  13. Create a new backup file that contains just those statements.
  14. Search for the "myexistingsubsite" string in your new backup file and replace it with "mynewsubsite" wherever you find it.
  15. Save the file. Get a little paranoid and double-check that the backup file contains only "mynewsubsite" string statements.
  16. Use Drupal's Backup and Migrate module to "Restore" the new backup file. All the tables needed for your new subsite will be created.
  17. Using phpMyAdmin or similar, check that the new database tables have been created with content.
  18. Using phpMyAdmin, empty (truncate) all the tables that are called "mynewwebsite_cache_ " something-or-other. (If you fail to do this, you may not be able to see the new subsite, and will just get the Drupal WSOD.)
  19. You should now be able to see your cloned Drupal subsite. If it still looks a bit odd, trying clearing your website's cache a few times.
  20. Now thoroughly check the entire site looking for any kind of problems. If you find none, you are done!

 

 

Reply

The content of this field is kept private and will not be shown publicly.
 
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <div> <pre> <address> <h1> <h2> <h3> <h4> <h5> <h6> <br> <p> <table> <tr> <td> <img>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.