Copying a Drupal site to a new Drupal virtual site

Copying a complete Drupal site to a new virtual site within the same Drupal installation is relatively easy. These are the steps to take:

  1. Take original site off-line to prevent changes while the copy is in progress.
  2. Copy site-specific files, themes and modules.
  3. Copy the site database (with phpMyAdmin select "Add AUTO_INCREMENT value" for this to work properly).
  4. Return original site to on-line state.
  5. Log into new copy and visit these admin pages:
    • Modules (updates the database with the new sites module paths)
    • Themes (updates the database with new site's theme paths)
    • Theme configuration if the theme's colours or logos etc. were configured.
  6. Edit the files table to point the filepath column entries to the files in the new location. Suitable SQL would look like:
    UPDATE files SET `filepath` = REPLACE(`filepath`, 'oldpathpart', 'newpathpart') WHERE `filepath` LIKE '%oldpathpart%';
  7. Return the new site to on-line state.

You might also need to empty the cache tables (use the Devel module, or phpMyAdmin) - this needs further testing, it might be unnecessary given the steps above.

Tags: