Migrating A WordPress Site – Step By Step

Whenever I develop a new site, or need to make extensive changes to an existing site, I like to do the work on a local install and then migrate the site to the live one.  This is a description of the process I use.  As of this writing, this has been used on WP versions 3.1 through 3.6.1.

Note that if you are changing a live site, it should be ‘frozen’ so no changes  can occur to it while you are working on the modifications. One way to do this is to install a ‘maintenance mode’ plugin that will let viewers know that the site is being modified.

I use two plugins to help in the process:

  1. BackUp WordPress
  2. WP Migrate DB

A. The first set of tasks is to prepare the ‘New’ site:

  1. Create a database and install WP on the New site.If I am trying to set up a local site from an on-line site, I use xampp on my pc and I try to name the database and site the same as the live site, but this is not strictly necessary.  In any case, install WP in the new site whether local or on-line.
  2. Install and activate both plugins.
  3. Run WP Migrate DB from the Tools menu, but only to get the values for ‘Current address (URL)’ and ‘Current file path’.  Save these values for later use.

B.  Next, get the data from the ‘Old’ (existing) site:

  1. Install and activate both plugins.  Configure BackUpWordPress as you like.
  2. For safety’s sake, run BackUpWordPress from the Tools menu and download the zip file to your computer.  This is a backup of the unchanged site for emergencies, so be sure to include the database in this backup.
  3. Update WP and all plugins to the latest working version.  This step is not absolutely necessary, but this is a good time to get everything current.
  4. Run BackUpWordPress again and download the zip file to your computer.  It is not necessary to back up the database during this step.
  5. Run WP Migrate DB from the Tools menu.  Use the values you saved in step A-3 above for ‘New address (URL)’ and ‘New file path’.  Save the output file to your computer.

C.  Now load the data into the New site:

  1. Unzip the backup file from the Old site.
  2. Edit wp-config.php and change the ‘DB_NAME’, ‘DB_USER’, ‘DB_PASSWORD’, and ‘DB_HOST’ to the values for the New site.  You can get these values from the wp-config.php file of the New site before you upload the Old site data.
  3. Note that the .htaccess file can contain rules that reference the Old site.  Any such references must either be removed or rewritten to reflect the New site.  One approach is to save a copy of the file from the Old site and then delete it from the upload.  Then add parts back in as needed.It is safe to remove lines between ‘# BEGIN WordPress’ and ‘# END WordPress’ because WP will recreate these lines, although you may have to assign Permalinks back to default and then back to the current assignment to trigger this.
  4. Use ftp to copy the files to the New site, overwriting the initial installation. If the WP version is the same for both sites, you can delete the wp-admin and wp-include folders from the backup to shorten the upload time. I always leave them in in case I overlooked an update.
  5. Use phpMyAdmin to import the database contents file produced by WP Migrate DB.
  6. If you have access errors, try going to Admin->Settings->Permalinks and just clicking ‘Save Changes’.  No need to actually change anything.  If you still have problems, check that you used the correct URLs when you exported the database.

If Lady Luck is smiling, you should now have an operating copy of the site!  Your login credentials should be the same as on the Old site.

19 Responses to Migrating A WordPress Site – Step By Step

  • Marissa says:

    I am stuck on part C #1

    I have gotten to that point but when I unzip my old site backup, there is only one file (.sql) inside the folder and I am unable to open it.

    I know this is not right as I don’t see wp-config.php… or anything else for that matter…

    ANY HELP WOULD BE MUCH APPRECIATED, THANKS!

  • Velanche says:

    Hello:
    I have tried following the directions about half a dozen times.

    When I go to localhost:8888, I get a white page, but I see that the site title exists when I hover the mouse cursor over the browser tab for the page.

    I then tried doing an end run by typing at localhost:8888/wp-login.php to get the login screen for WP. After attempting to authenticate, the base URL changes from localhost to velanche.com, and I get this:

    Error 403

    We’re sorry, but we could not fulfill your request for /wordpress/wp-login.php on this server.

    You do not have permission to access this server. Data may not be posted from offsite forms.

    Your technical support key is: c7bb-958b-cd36-1abb

    You can use this key to fix this problem yourself.

    If you are unable to fix the problem yourself, please contact dj at velanche.com and be sure to provide the technical support key shown above.

    I know that I’m close, but not sure how to get around this issue. I’d appreciate any guidance you can offer; thanks!

  • Mags Layton says:

    Happy happy joy joy! You are a genius – thank you so much, been struggling with this for a day.

  • Raj Choudhury says:

    Mac you saved my life and sanity.
    Thank you for this guide
    Amazing stuff, book-marked forever

  • Phil says:

    Thanks for these instructions. The only issue I had were 404 errors. This was fixed by temporarily changing the Permalinks (Settings > Permalinks) to default, then back to what it was.

  • Tom Murphy says:

    I was having lots of problems getting my live site downloaded and then imported to my localhost… but thanks to Mac… both in an online forum.. and even more so via Skype, I was successful! He helped me work through several “issues” that were unique to my site and helped me immensely. I am truly grateful for his help and his patience with me, a relative newby.

    I am now able to visit my site on http://localhost/pbgpf and it renders perfectly, including all of the internal hyperlinks!

    Thanks again Mac!

    Tom

  • I followed your instructions and I can now visit my site on http://localhost/mysitename and it renders perfectly, but none of the internal hyperlinks work. They all direct me to the XAMPP 404 page at http://localhost/xampp/. Is there some other configuration change I need to make (such as a .htaccess file somewhere)? Thanks.

    -Mike

  • Dan says:

    Mac,

    Have you ever seen or tried this: http://www.halty.net/website_mover_0.2.zip
    Claims to be compatible with wordpress but I am afraid to try it on my website

    Dan

    • Mac McDonald says:

      I have not used that script. In a very quick look I did not see where it handles embedded absolute file upload paths, but I could have just overlooked it.

      My best advice would be to back up thoroughly before using it and use on a couple of test sites first.

      • Dan says:

        Thank you!

        Apparently my webhost has a backup button which also saves the database, so i will be trying this, hope nothing horrible happens. Really do not want to mess things up.

  • Thanks for this, it worked!

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>