• Home
  • My Products
  • Reviews
  • WordPress
  • Learning
  • Things to Avoid

Marketing With Vladimir

Welcome to my Internet marketing laboratory

You are here: Home / WordPress / How to Migrate a WordPress Blog to a New Hosting

How to Migrate a WordPress Blog to a New Hosting

June 5, 2015 Leave a Comment

How to Migrate a WordPress Blog to a New Hosting

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.

Prerequisites

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.

The steps

We start with the source website, the one to be cloned:

1. Point the browser to the source site admin area (example https://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.

wp-clone-create-backup

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):

108.61.50.130 marketingwithvladimir.com

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 https://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.

MySQL-server-has-gone-away-workaround

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.

wp-clone-database-only

Conclusion

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.

Read Also:

  • Blog in Directory
    How to Move a Blog From Root to a Directory Part 2: robots.txt and .htaccess

    After I moved my WP blog from root to /blog/ directory I wrote this post where I explained how I did…

  • Wordpress Move
    How to Move a Blog From Root to a Directory

    During my early weeks' training within P2S coaching program, I was taught to make a fresh WordPress installation in /blog…

  • How to Add PHP Code to WordPress Without Touching the Theme

    There are times when you need to add customized filters or actions to a WordPress blog. The Problem When you…

About Vladimir

I have a solid background in computer networking and programming. I recently started to develop applications related to internet marketing.

« Do Not Use Unethical Marketing Practices
How to Move a Blog From Root to a Directory Part 2: robots.txt and .htaccess »

Leave a Reply Cancel reply

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


Recent Reviews

  • 24 Hour Profits – Review and Case Study

    24 Hour Profits – Review and Case Study

  • New Ultimate Stock Photos Package with MRR – Review

    New Ultimate Stock Photos Package with MRR – Review

  • CB Passive Income Review – A Fully Functional Free Version Included

    CB Passive Income Review – A Fully Functional Free Version Included

  • A Simple Way to Monetize your WordPress Blog – Content.Ad Review

    A Simple Way to Monetize your WordPress Blog – Content.Ad Review

  • The Bloggers Roadmap – Honest User Review

    The Bloggers Roadmap – Honest User Review

Recent Posts

  • How to Cancel All Friend Request Sent on Facebook in One Click

    How to Cancel All Friend Request Sent on Facebook in One Click

  • How to Auto Post Your Content to Facebook, Google+, Twitter and LinkedIn

    How to Auto Post Your Content to Facebook, Google+, Twitter and LinkedIn

  • Two Ways to Make YouTube Videos Responsive in WordPress

    Two Ways to Make YouTube Videos Responsive in WordPress

  • Subdomains vs Subfolders Usage Comparison

    Subdomains vs Subfolders Usage Comparison

  • How to Create Exit Intent Pop-ups Using Free Plugins

    How to Create Exit Intent Pop-ups Using Free Plugins

Affiliate Disclosure

While we receive affiliate compensation for reviews / promotions on this page, we always offer honest opinion, relevant experiences and genuine views related to the product or service itself. Our goal is to help you make the best purchasing decisions, however, the views and opinions expressed are ours only. As always you should do your own due diligence to verify any claims, results and statistics before making any kind of purchase. Clicking links or purchasing products recommended on this page may generate income for this website from affiliate commissions and you should assume we are compensated for any purchases you make.

About

  • About Me
  • Sign Up
  • Contact Me

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Disclaimer

Follow Me

Copyright © 2022 · Marketing With Vladimir

Get Comment Funnels For FREE (normally $197/m)

(Enter your name and email address below and click “Continue…” to complete)