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
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
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 2. Copy your entire Drupal site to your destination
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 3. 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 4. Create a database for this new installation
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 5. Get the information on the database for your original site
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 6. Visit the site and get ready for a standard installation
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 7. Enter the new database information
Enter the Database name, username and password. Click Advanced options and add the Table prefix.
Follow through the rest of the installation and visit your new site. Then enable all your modules.
Step 8. Activate the modules
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 9. Access Backup and Migrate
Click to Configuration > Backup and Migrate.
Step 10. Restore from your backup
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!