I’m a designer and developer, so I move WordPress sites a lot. Of course I also move clients between different hosting companies, between servers, create duplicates of their sites, and more. So I’ve gotten a lot of opportunities to test out WordPress migration approaches. Here is a breakdown of how to migrate a site using free tools.
Background
There are a lot of different tools and articles out there on moving sites. Most of them say how to move it between location X and location Y and make several assumptions about what will be at location Y. Unfortunately anything that comes with several assumptions doesn’t work most of the time. The following method works for going to OR from managed WP, going to or from cPanel, dealing with most hosting companies tools even if they aren’t cPanel (for example Plesk), and of course works whether you are wiping an existing install or starting with nothing.
Before we start warning: If you are not familiar with FTP, phpMyAdmin, and making absolutely no typos when editing a file, STOP. You need to hire a developer to do your migration and save yourself a LOT of headache.
By continuing on this tutorial, you realize that this is the manual method and could break the new site where you are trying to move WordPress to if a mistake is made.
Moving WordPress files
The good news is when moving WordPress to a new location, there is only 1 file that you actually have to modify.
Download the existing files
cPanel / Plesk
Many hosting companies provide cPanel, and this is both the easiest and fastest way to download your files. You’ll need to login to your cPanel and locate the File Manager. Go to the File Manager and find the location of your WordPress site that you want to download. This will be a folder that contains the wp-content directory and wp-config.php file for the WordPress site you want to move.
Select all of the files for WordPress and then click on Compress. It may take a couple of minutes for compression depending on how large your site is. Once you’ve compressed the files, click on the reload link (NOT reload on your browser) and you’ll see the .zip file you created. Double click on that file to download.
FTP
Most managed WordPress providers only have FTP access for getting to your files. In that case, you’ll need to login to your site using your favorite FTP client (I like cyberduck). You’ll want to make sure you download everything in your install. Since FTP handles each file individually, this can take a lot longer than just downloading a .zip file. Don’t be surprised at an hour for download.
BackWPup
This is the solution when you only have access to /wp-admin on your website. You can download your entire site by making an offsite backup. Personally I like using BackWPup and sending the file to dropbox. I’ve got an entire tutorial on using BackWPup to make a backup, so I won’t go into here.
Modifying wp-config.php
This is the one file that you may have to change when moving your WP site.
If you are overwriting an existing WP site (for example if you are bringing in a remodeled site or are overwriting a blank WP install), the easiest thing to do is just DON’T upload the wp-config.php from the old site. The one at the new location is already all setup.
If you are moving the WordPress site to a location which doesn’t have anything (such as a brand new cPanel), you’ll need to setup your wp-config.php file for the new location. You’ll need to change the following four lines:
/** The name of the database for WordPress */
define('DB_NAME', 'database_name');
/** MySQL database username */
define('DB_USER', 'database_user');
/** MySQL database password */
define('DB_PASSWORD', 'database_password');
/** MySQL hostname */
define('DB_HOST', 'localhost');
The name, user, password, and host will all be dependent on where you are moving the site to. In the installing the database section below I’ll talk about the name, user and password. For what goes into the host section, on many hosting companies it is localhost
. However, that could vary. The best way to find out for sure is to check the WordPress list of known hosts and if it’s not there, then contact your hosting provider for support.
Upload the files
If you are moving to a managed WP environment, you ONLY want to copy the files in /wp-content directory, and make sure you don’t copy any files generated by backup plugin or a caching plugin. Also, if you are moving to a managed WP environment, you will only have access to FTP for uploading the files.
cPanel / Plesk
The easiest thing when moving to cPanel to take a .zip of all of the files you want to upload (including your change to wp-config.php or NOT bringing wp-config.php at all). Then upload your .zip file to the directory where WordPress will reside.
Once there, remove any files you want to replace (being careful about your decision on wp-config.php) and then extract your .zip file. If the files didn’t extract to the location you intended, you can move them as needed so that the /wp-content directory and other wp- files are all in the directory that your WordPress install will reside.
FTP
If all you have for uploading the files is FTP, then use FTP (my favorite FTP client is Cyberduck).
You’ll need to upload all of the appropriate files (remember you can not extract a .zip file on FTP, so no trying to upload a .zip of everything).
If you going into a managed WP install, only upload the items in the /wp-content folder. If you bringing in a remodeled site, you may also want to only upload the changed files (provided you remembered what you changed). If you are putting in a brand new WP install, you’ll need to upload all files (including wp-config.php).
Moving your database
There’s a trick to a successful WordPress migration, it’s knowing how to handle serialized data. WordPress stores your menus, widgets, and theme settings in using serialized data. This means that WordPress cares not only about the content of the data, but also the string length. What this means is a basic text search/replace will break your data.
WP Migrate DB
To move your database you need to know the URL that the new site will reside on (if keeping the same domain and just changing hosting companies, this will not change) and the new file location. The file location is where your site’s files will be. If you have no idea, you can remove this line (better to remove than to enter wrong data, but try to find out the correct path since many plugins store data files for their preferences).
When entering the new URL, do NOT include http: or https:, only include the // then the URL. Your url may or may not have www in it, make sure you know before you do this migration. A single typo in these lines will break your site, so make sure there are no stray characters (and make sure you didn’t accidentally include a space anywhere).
When entering the file path, make sure that the Find file path is NOT / or /www. If it is, remove this line by the clicking the x at the end of the line. If you do a replace on either of these it will break your site!
Once you’ve entered the correct fields (or removed fields if unsure), click on Export. Migration normally takes about a minute, but on larger sites make 2-3 minutes. It very rarely ever fails. If it does, go to Settings and increase the Maximum Request Size to its maximum.
Installing the database
Now that you have a migration file, you’ll need to install it on the new location.
If you don’t have a database at the new location, you’ll need to create one. This is done through your cPanel and going to MySQL databases. You’ll create a new database (write down the database name), and new database user (write down the user name and password). If you were updating your wp-config.php file, you need to use these values in it.
Now that you have a database, you’ll open phpMyAdmin to install the new database. Select the database that you created, or the database that the site is already using (read the wp-config.php file to find out the database).
After clicking on the database to use, go to the import tab (if you have an existing database, first go to export and download the existing database) and import the file that was created by WP Migrate DB. If the file fails to import, it is most likely due to the zipping. Unzip the file on your computer and make sure it ends in .sql — if it does not, then after unzipping, add .sql and upload that file.
Check your database prefix
Once the new files are imported, make sure that the database prefix is correct. WordPress by default uses wp_ as the database prefix, however many security plugins and hosting companies may change that.
You’ll need to verify that the prefix in the wp-config.php file and the prefix for the database that you uploaded match. If they don’t, your site will not load. If you have a managed WP site, you can not directly edit wp-config.php, so you’ll need to find the place in your hosting dashboard where you can change the prefix. If in linux cPanel, you can just edit the wp-config.php file to make it match.
Page Builder Plugins/Themes
Important note: some of the page builder plugins and themes package URLs a little differently than the standard //www.example.com. What this means is if you are using a page builder plugin or theme, make sure that you double check your urls.
Visual Composer
Visual composer sets a number of URLs as http%3A%2F%2Fwww.example.com instead of http://www.example.com. This means if you are using Visual composer you’ll need to add a line to your WP Migrate DB. Here is how to format it for moving form www.example.com to sample.com:
Load your new site!
Ok, now is the time to go to the URL that you were moving to and load it. If everything went right, you’ll see your new site working smoothly.
If you see the content, but it looks like there is no CSS, it’s almost always a typo made in the WP Migrate DB step.
If the site is white or says DB connection error, the issue with the database and the wp-config.php file not agreeing. Check database name, user name, user password, host and prefix.
Site looks fine on the front end, but you have no permissions on the backend?
This is from changing the database prefix. Let’s say you went from wp_ to xyz_. Now your tables all say xyz_, but the content of the xyz_usermeta and xyz_options normally has some entries that say wp_ — so what you have to do is go in manually and update entries these to the new prefix xyz_ (this is very common with wp_capabilities and wp_user_level not getting changed on the migration (remember to check both wp_usermeta and wp_options tables).
Note: If you are changing hosting companies and have not yet changed your DNS, you’ll need to contact the new hosting company to see about the ability to preview the site — note that on preview you may only be able to preview the homepage until DNS changes are made.
Automated Migrations, Migration Plugins
Automated Migrations
When moving to a managed WP environment (such as WPEngine, Flywheel, or GoDaddy’s Managed WP) you will frequently be offered an automated migration. The theory behind these is that you enter a little data, click a button and come back after lunch and it’s all done. This works great when it works. Unfortunately it sometimes errors (and doesn’t work when going from one managed WP to another managed WP).
If you are moving from linux cPanel to managed WP, then you can setup a special FTP account which only includes the directory for the WordPress install you want to move. Then give that info to the managed WP automated installer, and it will usually work. However if it fails, go back to the top of the tutorial, because you need to do it the manual way.
Migration Plugins
Honestly, I hate these. They are extremely fussy, and tend to error. And when they error, they can bring down the entire site where you were trying to move to. Which is why I never use them. There are several out there which claim to work, and do work the majority of the time, however I just don’t like gambling with client’s websites. And even when they do work, I’ve found they may leave some remnants of the old site.
Conclusion
WordPress migration can be painful and end in disaster if you don’t have the right tools for the job or don’t know what you are doing. If you don’t know how to access phpMyAdmin or handle files, hire a developer to do your migration and save yourself a LOT of headache.