My first year subscription at SiteGround was approaching to it’s end and I was facing to the decision whether to remain with them or to move to another web hosting company.
I knew about D9 Hosting for a while and I heard only good things about them, so I decided to give it a try. I bought a three months subscription and after migrating one of my sites I figured out that it is about twice as fast as before! Wow!
In fact their servers are virtualized, and this allow each hosting account to better use the resources of the physical machines. Also, the word unlimited was very appealing to me.
Also it’s a small company and their servers aren’t so crowded. And the customer support is also top notch. 😉
But enough with the hype, let’s get to the business.
This tutorial contains all the necessary steps to move a WordPress blog from a hosting company to another. For illustration purpose I will use my primary domain name.
Before you start I recommend you to deactivate, or better yet, to remove alltogether any caching plugin. When finished you can install any caching plugin you may see fit for the new hosting. They could have their own solution, anyway.
Also remove any folders that might left after the cache plugin activity. Also remove any unused themes, they can add significant weight to the resulting backup file.
As a side note: in your FTP client it is preferable to use the servers’ IP addresses instead of your host names. This will ensure that the client will connect to the correct servers during the whole process.
We start with the source website, the one to be cloned:
1. Point the browser to the source site admin area (example http://marketingwithvladimir.com/wp-admin) and install WP Clone by WP Academy plugin. Hover over Plugins->Add New and search in WordPress repository.
2. Go to WP Clone admin page, create a backup and copy the generated link address to a text file, you’ll need it later.
3. Copy additional files:
a. Open the site document root folder (usually public_html) using an FTP client and copy .htaccess file to your local system. You’ll need it later.
b. Copy any other files and folders that are not part of WordPress installation, if any.
4. Login to the new hosting CPanel.
a. Create addon domain or use the primary domain.
b. Find out what IP address has your new server. Usually you receive this information in an email just after your hosting package activation.
5. Trick your local system into thinking that your domain points to the new hosting server:
a. open C:\Windows\System32\drivers\etc\hosts file on your local Windows machine
b. add a line like this (don’t forget to use your own data):
c. In the command window execute:
C:\> ipconfig /flushdns
6. Make sure to clear the browser cache, close and reopen it, possibly use Incognito window to access your cloned website later.
Now we move to the destination hosting:
7. Install WordPress manually or using Softaculous.
8. Open the destination site admin area using the same domain name (for example http://marketingwithvladimir.com/wp-admin).
VERY IMPORTANT: At this stage make absolutely sure that you are working on the newly installed WordPress, not on the original website! If you restore a backup over a working website you may lose it forever!
9. Once in the admin area, install WP Clone plugin, like in the source website.
10. Go to the WP Clone admin page and choose to restore from URL, providing the link address that we got in step 2.
It’s OK to use the same domain name here because the web server is not affected by the trick we used in step 5, only our local system. In fact, the destination server will retrieve the backup directly from the source server.
This step may take several minutes, depending on the backup size and communication conditions between the two servers.
After the cloning process has finished, you’ll typically see a confirmation message. Now go to the dashboard and you should have access to the cloned blog.
11. Open the document root folder on the new hosting using an FTP client and copy there .htaccess and any other files from step 3. You may have to reapply the permalink settings.
12. Try to access your website to see if anything is OK.
13. As the last step, go to your domain registrar account and update the name servers for your domain using the DNS names provided by the new hosting company. It usually takes up to 48 hours before the changes propagate over the whole internet.
14. You can now remove the line that you inserted in hosts file in step 5, and again execute ipconfig /flushdns command.
MySQL Server Has Gone Away
Sometimes, depending on MySql settings of the hosting provider, during the restoring process in step 10 you may encounter this error: “Error Message : MySQL server has gone away“. This happened to me, but I found a workaround in this article.
Basically, all you have to do is insert a line in wp-include/wp-db.php file to increase MySQL query execution timeout. In my current WP version (4.2.2) I found the spot around the line 1512. Here are the steps:
1. Open wp-include/wp-db.php in the destination WordPress.
2. Search for the string “public function db_connect” and go near the ending brace of the function.
3. Insert this new line
$this->query("set session wait_timeout=600");
just above this one:
$this->select( $this->dbname, $this->dbh );
You can increase the timeout amount if necessary.
This workaround solution worked for me and for many others.
The restore process failed
Sometimes, when the site has plenty of pictures and other media files, the restore process may fail.
In this case I recommend to create the backup using WP Clone advanced settings and select Backup Database Only. Then follow the steps outlined above and manually copy the whole wp-content directory from the old to the new server.
As for the overall cloning process, with the addition of the above workarounds, it worked flowlessly for all my sites!
For any questions you may have, please leave a comment. I didn’t dive too deeply into technical stuff, and to understand this guide you should be a little bit familiar with the file structure of WordPress. But should you find anything unclear or missing, don’t hesitate and give me a sign. I will update this post and add clarifications based on your comments.