Bluehost is a great service that is incredibly cheap, but depending on the amount of traffic that you receive, a Bluehost server may not be able to accommodate in performance. For example my WordPress blog, the one you’re on now, receives too much traffic, which is why I had to host it on a VPS service. In particular I’m hosting this WordPress blog on Digital Ocean. Now, not everyone needs more than Bluehost so don’t think it is a bad service from the start.
Before going forward I’m going to assume you’ve followed my previous guide regarding installing WordPress on a Digital Ocean VPS. You won’t need the latest version of WordPress, but if you’ve already downloaded it, no worries. From the previous tutorial we really only care to know that a database was configured and the WordPress CLI tool installed.
We’re going to start from our Bluehost cPanel. From the cPanel, scroll until you find the section that reads File Management and click the Site Backup Pro option.
The next screen should present you with several different backup options. We only care about Website Files and MySQL because that’s what we’re going to transfer to Digital Ocean. Go ahead and download a .tar file of both.
You’re done with the Bluehost stuff at this point. The rest will happen within our Digital Ocean Droplet.
Using Filezilla or the SFTP client of your choice, upload both backup files to the Digital Ocean Droplet. Depending on the size of your WordPress blog, this could take some time. When it is done, sign into your Droplet via SSH like so:
Of course replace 127.0.0.1 with the actual IP or hostname and root with whatever user you’re using.
The first thing for us to do is extract the MySQL backup archive. Enter the following, swapping out the tar file name with whatever your file is called:
tar -xvf backup_filename.tar
Now we need to import the MySQL database file. I’m assuming you have a MySQL database named wordpress and a username also named wordpress for that particular database. If not, alter the following command where appropriate:
mysql -u wordpress -p wordpress < backup_filename.sql
It will ask for the password for that particular user. Enter it when it asks.
Congratulations, your Bluehost WordPress database was migrated!
We may not be done with the database though. If you’re not migrating your domain name or are changing domain names you’re going to need to update the database to reflect. If you’re migrating the domain name from Bluehost as well, then don’t worry, your database is good to go. If not, you need to use the WordPress CLI to replace a particular string in various MySQL tables. The commands you want to run are as follows:
wp search-replace http://www.old-domain.com http://new-domain.com wp_hxvw_options wp search-replace http://www.old-domain.com http://new-domain.com wp_hxvw_posts
It is important you use the WordPress CLI and not try to change them yourself with SQL. The data is serialized and the CLI knows how to work with that data. Also note that your tables might be slightly different and may not include the hxvw part. If the above commands can’t find the tables, go ahead and determine them from the following:
mysql -u wordpress -p use wordpress; show tables;
Now we can officially call MySQL complete.
The final step here is to place the WordPress files correctly. Untar the WordPress backup by running the following:
tar -xvf wordpress_backup_filename.tar
Move the public_html directory to /var/www and rename it to html replacing the old html directory if it exists. Inside your WordPress backup, find the wp-config.php file as we need to change the database information to reflect our new credentials. Find the following and replace as appropriate:
define('DB_NAME', 'wordpress'); define('DB_USER', 'wordpress'); define('DB_PASSWORD', 'password');
Congratulations, your Bluehost WordPress filesystem data was migrated!
You can verify that it worked by navigating to your new (or old) domain name.
Bluehost, a great shared hosting service, will peak at some point in time if you get a ton of traffic. You may find yourself needing to migrate to a virtual private server (VPS) to accommodate site growth with performance. I for one am using Digital Ocean, but the simple steps I demonstrated should work fine for migrating to any other service.
Stay up to date on the latest in web, mobile, and game development, plus receive exclusive content by subscribing to The Polyglot Developer newsletter.