Site migration


At some point, you may need to change the hosting arrangement you’re using for your Drupal site. This may be because you’ve built it using free development hosting, and want to move it to a less expensive hosting option to launch the site. You may also need to migrate a Drupal site from your local computer to web-based hosting, or change hosting providers.

Exporting your site

If your site doesn’t have a lot of locally-stored multimedia (images, audio, video, etc.), you may be able to get away with using the “Backup my entire site” option using the Backup and Migrate module, as described in section 20.6.2. If your site does have a lot of locally-stored media, rather than packaging everything into a huge zip file that may time out as you’re trying to download it, you might want to export your database using Backup and Migrate (as described in section 20.4), and then download your code and files via SFTP (as described in section 20.5.3, but including everything in your entire Drupal directory, not just sites/default/files).

Importing your site

If your site (including all uploaded files) is small, you may be able to simply install an empty Drupal site (as if you were creating a new site), install the Backup and Migrate module, and restore your site from the zip file you exported using Backup and Migrate. However, if your site has even a moderate number of uploaded files, it’s likely that the zip file will be bigger than the upload limit. In that case, you may want to do the following:

  1. Install Drupal from scratch on the new server
  2. Connect to the new server via SFTP
  3. Download the settings.php file (in the sites/default directory) to your computer
  4. Unzip the zip file you downloaded from Backup and Migrate on your old server
  5. Replace the settings.php file in the unzipped folder (docroot/sites/default/settings.php) with the one that you downloaded from the new server
  6. Using SFTP, replace everything in the Drupal directory on the new server with the contents of the docroot folder in the unzipped folder. (Don’t include the docroot folder itself -- just open it up and drag and drop all the files within it into your SFTP client when you’re in the directory for your Drupal installation.)
  7. At this point, you’ll have a new Drupal site with all the modules, themes, libraries, and files of your old site. Go to that site and log in with the admin account you created when you installed Drupal on your new server.
  8. Enable the Backup and Migrate module.
  9. Use the Backup and Migrate interface to restore the database.sql file in the unzipped folder (from the zip file you downloaded from the old site).
  10. Cross your fingers and hope for the best.

If everything worked correctly, you should be logged out, but will see your old site in a form where everything appears messed up. Colors, fonts, layouts will probably all be wonky. This is because the Backup and Migrate export doesn’t include cache files, and most themes rely on the presence of those files to display correctly. Log in, clear the cache (if you have Admin Menu installed, hover over the house in the upper left corner of the Admin menu, and choose “Flush all caches”), and everything should be back to normal.

Alternately, this YouTube video walks through how to move a Drupal site from your local computer to an online hosting environment that uses cPanel. The process is quite similar.