Start a FREE 7 day trial! Get training videos and books, plus expert support:  

Drupal Tutorials and How-to Support Articles

Migrate or Duplicate a Drupal Site

Last month we wrote this tutorial showing you how to create backups using the Backup and Migrate module. Now we need to learn how to use it to either migrate or duplicate a site.

If you have an existing site, and need to make some changes or add modules, it's best to create a test environment that is identical to the production site. Do all your experimentation there and then it's a snap to migrate the changes.

This tutorial shows you how to migrate or duplicate your site using the Backup and Migrate module.

Step 1. Backup, backup backup

tutuploadstutuploadstutuploadsStep_1_5d03a547d4f9562c85b046b5f61da8f8.png

Got to Configuration > Backup and Migrate. For complete installation and setup instructions, follow the directions in our tutorial.

Save the backup to your local computer. You can do a Quick Backup or choose Advanced.

Step 2. Backup the database and download

tutuploadstutuploadstutuploadsStep_2_af0f6f7f3ee244e47f075379965756ee.png

Choose the Default Database > Choose Download > Backup now.

You can choose the Manual Backups Directory and restore from there when you've moved your site files. Any other destinations you created on the Destination tab when you set it up will also be visible.

TIP: I suggest the first time you try this that you also download a copy, and don't rely totally on the Manual Backups Directory. I found that trying to restore the first time from the Manual Backups DIrectory was less reliable. Files get corrupted in transfer occasionally and it's good practice to have a duplicate.

Step 3. Copy your entire Drupal site to your destination

tutuploadstutuploadstutuploadsmedia_1318359885964.png

Copy the entire site, or alternatively, you can download it to your local computer with FTP. There are several ways to move or copy all the files in a directory. Use a method you know you will work for you.

Step 4. Rename your settings.php file

On your test site, go to /sites/default and find your settings.php file and rename it. (You could delete it as well, but you will need to refer to the original later on). Do this on your local computer before FTP upload.

If this file is missing or renamed, Drupal will create a new settings.php file for you. When you visit the site for the first time you will go through the normal installation process. If you do it this way, all the paths and base urls will be correct for this installation.

You may have trouble renaming this file in an installed drupal site. In a normal Drupal installation, the permissions are set so this file can't be changed. If you haven't run setup yet, or you do it before you upload, you shouldn't have a problem.

Step 5. Create a database for this new installation

tutuploadstutuploadstutuploadsStep_4_74dc5e97c1b67e8a55a52ba86193702d.png

Use the control panel of the server, or phpMyAdmin to create a database for this site. If you are on a completely different server, you might want to create a database with the same name. If you are on the same server or in a sub directory of your main site, you need to create a new database name.

Step 6. Get the information on the database for your original site

tutuploadstutuploadstutuploadsStep_5_ec409559c39ee857be73fee7375a9c9a.png

Open the backup of the settings.php file you made, or look in the settings.php file on your original site. It's located in the /sites/default/ folder. Open it with an editor and look for the information. .

If you have created a new database, you will have all the required information except the database prefix. You will need that to make the content show, so be sure to record it after looking at the settings.php file.

Step 7. Visit the site and get ready for a standard installation

tutuploadstutuploadstutuploadsStep_6._Visit_the_site_and_get_ready_for_a_standard_insta.png

When you visit the site you will see the standard installation screen. Click Save and continue.

NOTE: You need to have created a database for this before you started.

Step 8. Enter the new database information

tutuploadstutuploadstutuploadsStep_7_d01bcd67782d891a09afc5f26b63d13b.png

Enter the Database name, username and password. Click Advanced options and add the Table prefix.

tutuploadstutuploadstutuploadsmedia_1318363229386.png

Follow through the rest of the installation and visit your new site. Then enable all your modules.

Step 9. Activate the modules

tutuploadstutuploadstutuploadsStep_8._Activate_the_modules.png

Go to Modules, scroll down and put a check mark in the box next to the Backup and Migrate module. Activate Pathauto and Token, these are needed to run Backup and Migrate. You can also go through the entire list at this time and enable all necessary modules.

Click Save Configuration.

If you made a complete copy of the original site, all the modules should be here and installed ready to activate. If you are doing this in a new installation, upload everything in the old sites folder (except the original settings.php).

Step 10. Access Backup and Migrate

tutuploadstutuploadstutuploadsStep_9._Access_Backup_and_Migrate.png

Click to Configuration > Backup and Migrate.

Step 11. Restore from your backup

tutuploadstutuploadstutuploadsStep_10_0a9f4630338a206122476d155c331d23.png

On the Restore tab, browse to the backup file you saved on your computer, click Restore now.

Visit the site to see if everything is correct. If you see a duplicate of your original site, you've succeded!

 

 

Start a FREE 7 day trial! Get training videos and books, plus expert support:  

License

All of our tutorials are published under the Creative Commons Attribution-NonCommercial license. This means:
  • You can re-use these tutorials.
  • You can modify these tutorials.
  • You must link back to our original tutorial.
  • You can't use these tutorials commercially.
Click here to read the full license.