The Ultimate Guide to Cloning a WordPress Site From One URL to Another

Post written by David Wells
On Friday, September 21st, 2012

cloning wordpressIf you have a solid modern hosting provider, you can use ManageWP to clone one site over to another.

If this isn’t the case… or if your host is being a pain, you might just have to do it the old fashioned way.

In this tutorial I will show you have to export an old WordPress site database and import it into the new destination site.

This will effectivly clone and be an exact duplicate of the original site on that new URL or server.

These steps will clone over your entire old WordPress site including:

  • All posts and pages
  • All plugins and themes
  • All current widget areas and their correct positions
  • All Plugin settings from your old site

Click on images to enlarge them in the tutorial.

First Things First You Need the Old Site’s Database

To export your old site’s WordPress database you need to head into the phpmyadmin section of your hosting provider.

Every hosting provider is a special snoke flake when it comes to how you can get to your phpmyadmin section, so I won’t be covering that here. Google “Hostname phpmyadmin” and hopefully you can find some documentation.

Once you are logged into PHPMyadmin, you should see something that resembles the screenshot above (older versions of PHPmyadmin might look slightly different but the principles here are the same)

You will need to select the correct database to export. If you do not know the database name you will need to figure that out from your wp-config.php file on your old wordpress site. (See screenshot below)

Finding Your Database Name

Search for the line that looks like define(‘DB_name, ‘YOURDATABASENAMEISHERE’);

That second value is your database name.

Once you know the Database name drill into the database in phpMyadmin by clicking on its name on the left hand side. You will then see the above view.

These are all the tables containing all of the data on your old WordPress site. Go ahead and click export at the top.

Save as .sql file

Leave the settings as they are and click Go. This will download your old MySQL database we are going to use to clone this site!

Setup and Install WordPress for the new site

Go ahead and setup a new wordpress install for your new site.

Then you are going to want to download everything from your wp-content folder of the old site and then upload that to that new wordpress installs wp-content folder.

The wp-content folder has your old sites themes, plugins, uploads etc.

Find and Replace in old site’s database

So by now, you should already have exported your old sites MySQL database and have that file on your computer and have your new blank wordpress site up and running.

What you want to do is open up your MySQL export file ( a .sql file) with a text editor. Use Notepad++ on Windows or Textwrangler on Mac (It doesn’t matter too much what you use as long as it has find and replace functionality)

Make a copy of the .sql file before making any changes, just in case you screw the pooch.

Now, Find and replace all instances of your old URL.

So find www.oldsite.com and replace with www.newsite.com in that open text document. Make sure you are replacing the www.oldsite.com with the location of that fresh wordpress install you just set up.

if you mess up on this step, don’t worry you have that backup remember? Also, you can quickly do a find and replace of the incorrect values in the database you are editing.

Clear out the new WordPress installs Database and Import the old

By now you should have edited the old MySQL database and updated the URLs to fit the new destination site, installed a brand spanking new version of WordPress for the new site and uploaded the entire wp-content folder from the old wordpress site.

On the new site hosting provider, go ahead and log into phpMyadmin just like in the first step (do this for your new site and make sure you are in the new database, it should have a different name than the earlier exported database)

Open up the new mysql DB by clicking into it (just like before). You should see something similiar to the screenshot above.

Now check all tables and click drop. It will ask you to confirm the drop, go ahead and do that.

Now your fresh WordPress install is totally naked with no data! Not to worry though, you are importing your old database next.

Click on the Import Tab

Click on Import Tab in new database with the freshly dropped tables then import your old site .sql file (the one that has been edited with find and replace to reflect the new url) then click go.

That file will upload and the old wordpress data will now be in that new WordPress site’s database.

That should be it! WOOOOOOT!

You did it! Go grab a beer.

If it’s not working, do the next step.

(Continue) You might need to update database table prefixes

Sometimes the prefixes in the databases can be different.

For example the database prefix for all the the above examples is “wp_” your database might be different.

You will need to update this on your new wordpress installs wp-config.php file. See image below

Update Table Prefix in wp-config.php (if necessary)

So in your wp-config.php file look for $table_prefix. If your old database has a different table prefix, go ahead and update this line and save the file and reupload it to your server.

That should get everything working properly! After cloning the live over to that new live URL make sure you properly setup 301 redirects from the old URL to the new site to preserve SEO juice.

Boom goes the dynamite.

About the Author:
David is Founder of Inbound Now and a Fanatical WordPress Designer & Developer. He believes that the internet is a magical place where wonderful things can happen. Say hi to him @DavidWells

Signup and get started with Inbound Now

Sign Up for Free

Download

[gravityform id="3" name="Popup Form" title="false" description="false" ajax="true"]