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.5.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:
A. The first set of tasks is to prepare the ‘New’ site:
- 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.
- Install and activate both plugins.
- 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:
- Install and activate both plugins. Configure BackUpWordPress as you like.
- 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.
- 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.
- Run BackUpWordPress again and download the zip file to your computer. It is not necessary to back up the database during this step.
- 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:
- Unzip the backup file from the Old site.
- 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.
- 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.
- 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.
- Use phpMyAdmin to import the database contents file produced by WP Migrate DB.
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.
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.
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
The htaccess file can definitely cause problems. Did you read step C3?
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
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.
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!