Have you ever thought about moving your WordPress website? Better yet, have you ever thought of creating a duplicate or backup of your WordPress website to use as a clone for reproduction?
If you are a webmaster or domainer, chances are you’ve heard of WordPress and have possibly used it and if you’ve been around a while, you may even have several or many WordPress sites up an running. Either way, at some point you may want to move or copy your website so let’s get going.
WordPress consists of two major components which make up an actual website, data and files.
- Database – is a database of tables that stores all of the content of your website. This will contain every stitch of content on your website including users, links, basically everything.
- Files – These are the actual files and directories (folders) stored on the server of your host. A file manager is where you’ll find these. Files are what makes your website look like it does and communicate with the database to display your website information within the confines of css and templates.
In my case, I have a small business website where I installed a bare bones, WordPress 2.7.1 with nothing but Maintenance Mode installed and a customized temporary landing page. The objective is to duplicate or copy my website onto another domain name to save time. Some may do this differently but I’m going to list my steps below how I do it.
Seven Quick Steps to moving your WordPress site:
- Backup database tables
- Backup and download WordPress files
- Upload WordPress backup .tar file to new location
- Change wp-config file (database access)
- Import tables to new database
- Run mySQL queries in phpMyAdmin
- Update WordPress General settings
Step 1 – Backup WordPress database
While there are of course, many ways to do this I prefer going right into phpMyAdmin in cpanel and clicking on my wordpress database and then clicking on export and making sure all the tables are selected. I use the “zipped” compression level and save it to a folder on my hard drive. I like to call mine, Site Recipes. So now I have a backup of the basic tables within database, now what?
Step 2 – Backup WordPress files
- Go into File Manager and to the directory where WordPress is installed.
- Select All the files – Usually there’s a checkbox.
- Compress Files – in cpanelX theme there is button for that. I use the .tar selection when it prompts me.
- Download the file you just compressed into the same folder as your database tables.
Now that I have both a database backup and a file backup we’re going to have to put these both on the new server. There are a couple things that you should have completed in order to move your website… like a new host or a new cpanel account or simply a sub-directory or add-on domain. In my case, I’m moving this WordPress site from domain ‘A’ to domain ‘B’ so I have the necessary elements already set up. These are my Cpanel hosting account and I’ve created a database with username and password.
Step 3 – Upload and Extract WordPress Tarball to location
Do not extract that .tar file you downloaded, simply use an ftp program or cpanel to upload it to your new domain where you’ll be moving the site. On my hosting account with Hostgator, my files are stored in the /public_html/ directory. This is the web accessible directory, (when you go to www.yoursite.com it automatically takes you to the /public_html/ directory on your server. In there it’s going to look for an index file. So upload that backup to the location of your new website and extract it there.
In cpanelX 11, you can do this within cpanel. Just select the file and extract it to the location on your server that it was uploaded to, change nothing. We uploaded to /public_html and that’s where we will extract it.
Step 4 – Change wp-config
There are three things in the wp-config.php file you’ll want to change, (This file is located in the directory you unzipped the wordpress backup in. The three changes are: (in bold)
/** The name of the database for WordPress */
/** MySQL database username */
/** MySQL database password */
Cpaneluser – refers to your cpanel user login name which is a prefix followed by an underscore then the database name and username. This information is needed to communicate with the database.
Step 5 – Import the WordPress Database Tables
Now that we have the files and all have been uploaded and extracted and we have configured the WordPress files to communicate with your database, we must now populate the database with the tables we saved from our site recipe or site backup. Once we have the new database tables in place we’re going to have to run some database queries using the MySQL replace() function to change links within the database. You’ll need to stay in phpMyAdmin to do this step.
Step 6 – Run MySQL Queries to Change the WP Database Links
First SQL querie we’re going to run is replacing the siteURL in the database. Rather than looking for the exact table, just select the database we added tables to and select the 2nd tab, SQL.
UPDATE wp_options SET option_value = replace(option_value, ‘http://www.old-URL.com’, ‘http://www.new-URL.com’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;
The next database query we will run is going to replace the URLs within the WordPress posts and pages and stored in wp_posts. Here is the querie:
UPDATE wp_posts SET guid = replace(guid, ‘http://www.old-domain.com’,’http://www.new-domain.com’);
Again, simply replace the old-domain with your new domain name leaving everything else in tact. The last query we will run is going to replace links within posts or internal links.
UPDATE wp_posts SET post_content = replace(post_content, ‘http://www.old-domain.com’, ‘http://www.new-domain.com’);
Now that all the links are changed within wordpress, we are almost done.
Step 7 – Change your WordPress General Settings
Login to your WordPress now under: yourdomain.com/wp-admin and go to settings, general and change the information in there including your email address and the name of your website.
That’s it! Your new wordpress site should be up and running. Below are several links to other methods of moving your wordpress website that you may find helpful.