Share on facebook
Share on twitter

How to Migrate WordPress to Google Cloud [2019]

If you want to know how to migrate WordPress to google cloud, Definitely this post will help you.

There are multiple ways, you can transfer WordPress to google cloud. But in this post you will learn about two methods.

  1. Manual WordPress migration method.
  2. WordPress’ migration using a plugin.

Before you start this tutorial, you should have lunch a WordPress on google cloud platform. Here is the post (WordPress on Google Cloud: The Definitive Guide) which will help you in this regard.

Contents

FAQs,

What is WordPress migration?

If I simply put this, WordPress migration is the process of moving  your hole WordPress website from one server to another without affecting its functionality. If you have a WordPress website, and want to move it on google cloud platform, then WordPress migration  is the way of achieving it. You can move your WordPress manually or by using a free or paid WordPress plugin.

How safe it is?

WordPress is nothing like a typical software which you might install in your PC. Your hole WordPress website is a stack of files which is stored in a folder. And your data such as login user, password etc. are stored in MySQL data base which you can access through myPhpAdmin panel. To migrate your WordPress to Google cloud server you have to move your WordPress folder and MySQL data to new GCP sever, that’s all. If you don’t mess it up, The migration process is petty much safe.

How to transfer my WordPress to google cloud platform?

In the above image I tried my best to give you a graphical view of WordPress migration. As I told you already your WordPress website is stored in a folder and your data is stored in MySQL data base, if you move those  to new server and point your DNS to new server, then You will successfully transfer your WordPress to Google Cloud.

Manual vs Plugin (WordPress Migration):

If you  ask me, what is the best way of transferring WordPress to new server ?  I would say manual migration is better, though the process is little complicated than plugins but you will have exact copy of yours WordPress. I recommend you to use plugins when you also wanted to change your domain name. Plugins normally skip unnecessary file such as cache files, but if the plugins not properly updated it may skip important files.

Here what happen when I use all those three processes on my WordPress website :
My WordPress folder is =1.01 GB
Manual process zip is =605.08 MB.
Duplicator Plugins created a transfer file which is 190 MB.
All in one migrate created a transfer file which around 400 MB.
 As you can see plugins do skip some unnecessary files.
***note, don’t compare the file size  of Duplicator with All-in-one. The process of installing WordPress is different that why their file size is different.

Migrate WordPress to Google Cloud Manually :

To migrate WordPress to google cloud you have to follow those basic steps below.

  1. Compress (Zip) your WordPress files folders.
  2. Create a copy of your MySQL database.
  3. Upload WordPress .zip file and MySQL .sql file to google cloud server.
  4. Point your DNS to google cloud.

Though the first step is “compress WordPress files” but 

On your existing hosting server:

Step 1: Compress WordPress files

Though the first step is “compress WordPress files” but our main object here is to transfer your WordPress files to google cloud. Your WordPress website can have over 2000-3000 files, so  If  you don’t compress those files, it will be a time-consuming process. The best way to compress your WordPress files is to create a .zip file out of it.

If you are using Web Panels such as CPanel, Plesk , CWP, etc then you don’t need to install any extra application. But if you don’t have any web panel then you have to install zip on your server.

For web panel users:

Login to your existing hosting account, navigate to the File Manager, and into the folder with the WordPress files. Compress (zip) all your WordPress files.

For CPanel users:

Login to your existing cPanel account, then navigate to File manager.

After that open the folder “www” which should be store in your home directory

If your cpanel hosting account is configured with multiple domain names, then you can find multiple wordpress folder in your home directory.

As you can see on my cpanel account I  set up multiple domains that’s why I have multiple WordPress folders in my /home directory.

Next, Select all the files and folders (in www directory)  and press the right button of your mouse. After that click on compress.

As you can see I created an example-com.zip file in my www directory which have my all WordPress files and folders.

Backup WordPress:

Now you can easily download the zip file by opening the below URL on your web browser.

http://your-domain-name/example-com.zip

eg. https://www.siteyaar.com/siteyaar.zip

Note: Please change the your-domain-name to your domain name and example-com.zip to your .zip file name.

Compress file without using Web panels:

If you don’t have any web panels such as cpanel, plesk  then you have to install zip application on your hosting servers.

To install zip program execute the command on your Linux server  terminal.

On Debian or Ubuntu Linux:

sudo apt-get install zip

If you are useing Red Hat Linux/Fedora/CentOS then,

sudo yum install zip

After you successfully installed zip, the next step is to create a zip archive, containing all of your necessary WordPress files.

Some time people face problem finding their WordPress files. The default location is /var/www/html, But if you are using any installer or third party OS manager such as bitnami then you WordPress files might stored in a different location.

To create a WordPress zip file execute the command below:

sudo cd /var/www/html
sudo zip -r give-a-name.zip *

The above command will create a zip file on your html (website ) directory. You can download the zip file by opening the below URL on your browser.

http://your-domain-name/example-com.zip
eg. https://www.siteyaar.com/siteyaar.zip

Note: Please change the your-domain-name to your domain name and example-com.zip to your .zip file name.

Step 2: Export The MySQL database:

I already told you that MySQL database is a key part of your WordPress website, It stores all of your important data such as passwords, logging details, post and page details etc. Without MySQL database your website does not open.

To migrate WordPress to Google cloud  you have to export an exact copy of your database to google cloud. There are multiple ways to do that but in this tutorial I will show you about three methods.

Here the three methods:

  • 1) Export database using myPhpAdmin.
  • 2) Export database using a free WordPress Plugin.
  • 3) Export database using terminal (command line).

1#. Export database using myPhpAdmin.

MyPhpAdmin is a very popular database manager program. If you are using cPanel, then definitely you will find it on your cpanel admin console.

If you could not find myPhpAdmin then ask your hosting provider about it, they definitely will help you. 

 

For Cpanel users :

Login to your cPanel account and navigate to Database >> phpMyAdmin.

If you are not using any web panel then you have login to phpMyAdmin using your root MySQL credentials.

Next, Select the database that contains your WordPress installation from the list on the left-hand sidebar.

Once you selected the database click on the export tab from the top navigation menu.

Select the ‘Export method’ as  Quick, after that choose the export ‘Format as SQL. Next click the ‘Go’ button to begin the export process. After the process is completed, a file will be downloaded to your local computer.

2#. Export Your database using a free WordPress Plugin

Login to your existing WordPress account and navigate to Plugins >> Add Plugins, Then install and activate the UpdraftPlus WordPress Backup plugins.

After you have activated the UpdraftPlus Plugin, Go to ‘Backup/Restore, Then click the Backup Now button.

Next, select only the first option which is ‘Include your database in the backup(…)’. After that, click the Backup Now button. 

After the backup process is completed, Click the Database button to download the SQL database file.

3#. Export the database using Command Line (Terminal)

If you have terminal access then database migration is an easy task. If you are using VPS or Dedicated server then surely you can access  command line, but if you are using shared hosting then you have to take permission from your hosting provider.

Open your server’s terminal then execute the following commands to complete the export process.

mysql -u root -p

The above command will ask you a password, enter the root MySQL password.

mysql> SHOW DATABASES;

The above command will show all the available databases.

mysql> EXIT; 

If don’t want any hassle of downloading and uploading the SQL file then you should save the file on  your  existing website’s root directory.

The default location of your public HTML root directory is /var/www/html or  /var/www/html/wordpress.

Go to your public root directory by executing this command:

cd /var/www/html

After that, execute the command to create database SQL export file.

sudo mysqldump -u -p --opt your-database-name > give-a-file-name.sql
How to Download the SQL database file?If you save the sql file on your plublic root directory then open the below link in you local computer brouser.
http://your-domain-name/your-sql-file-name.sql

eg, http://www.siteyaar.com/siteyaar.sql
You also can use FTP or SFTP to downoad the sql file.

On Google Cloud Server:

After you successfully created .zip and .sql (database file) on your existing website’s root directory, now is the time to configure your Google cloud WordPress.

To migrate WordPress to google cloud follow the GCP WordPress configuration steps:

  • Create and import MySQL database.
  • Import your exiting WordPress and configure your wp-config.php.

Step3: Create New MySQL database:

To complete your WordPress migration on google cloud you have to create a new MySQL database and then upload your existing data s to that new database.

Below, I will show you two different ways of completing the process.

Using myPhpAdmin:

If you are using Google click to deploy WordPress then you can access phpMyAdmin thorogh your domain name eg, http://example.com/phpmyadmin, but bitnami WordPress user only can access phpMyAdmin through puTTy SSH tunneling. 

Step 1: Create New Database

Login to phyMyAdmin using your MySQL root credentials.

Next, Click on the ‘New’ button from the top left-hand corner.

On the ‘Create database’ field, give a new database name then choose the utf8_general_ci. After that, click the Create button.

Step 2: Import your existing database.

Next, click on the new database and navigate to ‘Import’ from the top navigation menu.

To import your existing database, click on Browse and select the SQL file which you have  downloaded in the previous step. After that, click the ‘Go’ button.

Step 3: Create a new database user

Now, go to ‘Privileges’ from the top navigation menu. Next click on ‘Add use account’ button.

Next, type a new user name on the ‘Username’ field. Select ‘local’ from ‘Host name’. After that type a strong password.

Make sure, you enable  the ‘Grand all privileges on database ‘your-created-database-name’.

Lastly, click the ‘Go’ button to create a new user.

Using SSH Terminal:

Login to your Google cloud console and navigate to Compute Engine >> VM Instances. Click the SSH button.

On the SSH terminal execute the following commands:

To open MySQL monitor,

sudo mysql – u root -p

You will be asked for password, you have to enter your MySQL root password.

To create new database execute this command below:

mysql> CREATE DATABASE give-a-database-name CHARACTER SET utf8 COLLATE utf8_general_ci;

To create a new user execute the command:

mysql > CREATE USER 'wp_wordpres'@'localhost' IDENTIFIED BY 'enter new password';

To grant all permition to the new user,execute the command:

mysql> GRANT ALL ON example.* TO 'wp_wordpress'@'localhost';

.mysql> FLUSH PRIVILEGES;

mysql> EXIT;

Step 4: Import your existing database.

1#. Upload The Data

To import  the database file execute the command:

cd ~/

wget http://your-domain-name/your-sql-file-name.sql

---OR---

Click the settings’ icon from the right top hand corner and go to Upload file option. Next select the SQL file.

2#. Import the data tables to your new database

On your ssh terminal execute the command:

sudo mysql -u root -p new-created-database-name < your-uploaded-sql-filename

Step 5: Import your exiting WordPress and configure your wp-config.php

On your SSH terminal execute the following commands:

Navigate to public root directory:

#for google click to deploy

cd /var/www/html

#For bitnami wordpress

cd /opt/bitnami/apps/wordpress/htdocs

Remove the existing WP files

Execute the following  command to remove the existing WordPress files from your Google cloud.

sudo rm -rf  *

Upload the compress zip file

If you save the compress zip file in public root directory of your existing WordPress then execute the command below,  Otherwise you have to upload it through FTP or SFTP.

sudo wget http://your-domain-name/your-zip-archive-name

Unzip the files

To unzip the file type the below command and press enter.

sudo apt-get install -y zip unzip

sudo unzip your-zip-archive-name.zip

Edit wp-config.php

sudo nano wp-config.php

Execute the above command and update the DB_NAMES, DB_USER, DB_PASSWORD with new database name, user and password details.

Next, use your down arrow button to scroll down.

Change the WP_SITEURL and WP_HOME  to,

Option 1,

define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/');
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/');

Option 2,

define('WP_SITEURL', 'http://35.256.45.4/');
define('WP_HOME', 'http://35.256.45.4/');

After you pointed your DNS to google Cloud external IP address change it to like this,

define('WP_SITEURL', 'http://www.siteyaar.com/');
define('WP_HOME', 'http://www.siteyaar.com/');

To save the changes press CTRL+O then CTRL+X or  CTRL+X  then type Y and ENTER.

Restart Apache and MySQL

Lastly, restart the Apache and MySQL server.

For google click to deploy,

sudo systemctl restart apache2
sudo systemctl restart mysql

For Bitnami wordpress,

sudo /opt/bitnami/ctlscript.sh restart apache
sudo /opt/bitnami/ctlscript.sh restart mysql

Migrate WordPress to Google Cloud using All-in-One WP Migration plugin:

All-in-One WP Migration plugin is one of the best WordPress migration plugin available in the market. It can transfer your existing WordPress to new server with just three, four clicks. 

Only problem, you could face with this plugin is the 512 MB restriction. You can not import more than 512 MB with the free version of this plugin. The paid version is available at the cost of $69 (lifetime).

On existing WordPress:

Login to your existing WordPress website, head over to “Add Plugins” and download the All-in-One WP Migration plugin.

Activate the All-in-One WP Migration plugin. After that navigate to Export To >File. Then download and save the export file on your computer.

Ignore this step if you don’t want to change your existing domain name.

If you want to change your domain name then click on “ADD”, Then place your current domain name and new domain name. After that create your export file.

On Google Cloud WordPress:

Now login to your new WordPress website which is in google cloud platform. After that download the All-in-One WP Migration plugin and go to Import > Import From > File. Select the export file that you downloaded in the previous step.

NOTE: By default, on the Free version of  All-in-One WP Migration plugin, only allows a maximum file upload size of 100 MB. You can increase it to 512 MB by installing another free plugin.

If your maximum upload file size is 100 MB or less than 100 MB, then download and install the All-in-One WP Migration File Extension plugin.

Activate the All-in-One WP Migration File Extension plugin.

All-in-One WP Migration File Extension plugin will increase the 100 MB cap to 512 MB.

Migrate WordPress to Google Cloud using Duplicator plugin:

On existing WordPress:

On your existing WordPress, head over to “ADD Plugin” section and Install the Duplicator plugin.

After you have installed and activated Duplicator, navigate to the Duplicator >> Packages and click on the ‘Create New’ button in the top right corner.

After that, click the ‘Next’ button. And follow the steps to Crete your migration package.

Make sure that your scan results don’t have any RED mark or error. Next, Click the Build button.

This process will take several minutes to complete, the processing time is depended on your existing server CPU power and website total size.

Once the Build process is complete, you’ll see download options for Installer and Archive package. If you click the One click Download button, it will download both the files on your Computer.

After you have downloaded the installer.php and *archive.zip  files, go to your browser’s download section and copy and save the archive.zip file link.

On Google Cloud WordPress:

Login to your Google cloud console and navigate to COMPUTE ENGINE > VM INSTANCES. Next click on the SSH button to open the terminal. There are another options to SSH into google cloud. Check out this article to learn more.

The first thing you need to take care of is MySQL Database. You have two options, You can use your existing MySQL database (on google cloud) or you can create a new MySQL database.

If you want to create new database, then follow the MySQL database create section on ‘How to Manually Migrate WordPress to Google Cloud:’.

How to use your existing MySQL Database on google cloud?

To use your existing MySQL database you have to note down DB_NAME (Database name), DB_USER(database username), DB_PASSWORD (database user password), DB_HOST (database host) from your wp-config.php file.

For Google click to deploy WordPress users:

Open the SSH terminal, execute the command below:

cd /var/www/html
sudo nano wp-config.php

For Bitnami WordPress users:

Open the SSH terminal and execute the following commands below:

cd /opt/bitnami/apps/wordpress/htdocs
sudo nano wp-config.php

2#. Empty your root WordPress directory.

Go to  SSH terminal  and execute the following commands:

On click to deploy WordPress

cd /var/www/html
sudo rm -rf *

On Bitnami WordPress

cd /opt/bitnami/apps/wordpress/htdocs
sudo rm -rf *

3#. Upload Installer.php

On the right top corner of your Google cloud web ssh terminal, Click the setting logo button. After that click the upload file button and upload the installer.php file.

After that execute the following commands:

On click to deploy WordPress,

sudo mv ~/installer.php /var/www/html/

On Bitnami WordPress,

sudo mv ~/installer.php /opt/bitnami/apps/wordpress/htdocs

4#. Upload archive.zip file:

You can use SFTP OR FTP to upload the archive zip file, but here I will show you a little easier way of doing it. I already told you to copy the archive.zip URL, here is the time to use it.

On click to deploy WordPress,

cd /var/www/html/
sudo wget paste-the-archive.zip-url

On Bitnami WordPress,

cd /opt/bitnami/apps/wordpress/htdocs
sudo wget paste-the-archive.zip-url

5#. Start the Duplicator Migration Process

Go to your Google Cloud Console panel and navigate to Compute Engine > VM Instances, and copy your External IP address.

After that open the below link on your browser.

Your -external-IP/installer.php
eg,  35.255.187.62/installer.php

The Duplicator will run a few tests and show you “pass” next to archive and validation tests, 

You need to check the terms & conditions checkbox and continue by clicking on the Next button.

Now, Duplicator will be asked you to enter your MySQL database details.

Now, enter the database details which you noted down from wp-config.php in the previous step. If you created a new data base then enter the details of that database.

You can click on the ‘Test Database’ button to make sure you entered the correct information.

After that click on ‘Next’.

Now, Duplicator will ask you to update site URL. Don’t change the URL to your domain name, unless you point your DNS to google cloud VM external IP address.

I recommend you to test the migrated website thoroughly, before you point the DNS to google cloud.

You can now login to your WordPress site on the  Google cloud.

Update Your Domain Name Servers (DNS)

At this point, you have created a complete copy of your WordPress website on google cloud platform which you can access through your VM’s External IP address. 

To access your Google cloud WordPress through your domain, you have to points your DNS to Google Cloud VM Instances external IP address.

If your existing hosting provider is a manage host such as a2hosting, siteground, namechape, godady etc, then it is more likely you are using their default DNS server.

Though you can use their DNS server for testing purposes but I don’t recommend using it as primary DNS server, because when your subscription package ended they might delete your IP records from their DNS server.

Not recommended: How to use your existing provider DNS server?

Login to your cPanel and navigate to DOMAINS >> Zone Editor >> Manage. After that change the “A”  record to google cloud external IP address.

The recommended way:

To update your domain, I  Recommend you to switch your DNS nameservers to Cloudflare/AWS DNS (Router 53)/Google Cloud DNS. You also can use your domain register default DNS server, but they are much slower than the recommended ones.

For the sake of this guide, I will be showing you how to change DNS nameservers with GoDaddy, NameCheap.

Depending on your domain registrar, the screenshots may look different. However, the basis concept and functionality is same.

On GoDaddy

Login to your GoDaddy account and then navigate to  Domain Manager >> DNS. After that, scroll down to ‘Nameservers’.

Option 1: Use your domain registrar DNS Server

To use your domain registrar (here godaddy) DNS server as your primary DNS server select ‘Default’ from ‘Choose your new nameserver type’ field.

After that, click on save button and reload the page from your web browser.

After the page is  reloaded , you will see some new options. 

Now, Click the pencil logo, on your right-hand side to edit the ‘A’ record.

Next, place your Google cloud  server IP address on ‘Points  to’ field. Then click the save button. 

@ mean your domain name.

Option 2: Use third party DNS Server

To set up with third party DNS provider  such as Cloudflare(as DNS), google cloud DNS, AWS route 53 etc, select custom from ‘Choose your new nameserver type’ field. After that, click on save button.

To complete your set up you have to add ‘A’ record from your DNS providers admin console.

On NameCheap

Login to your NameCheap account, then navigate to Domain list >> Domain. After that scroll down to ‘NAMESERVERS’.

Option 1: Use your domain registrar DNS Server

To use your default Namecheap DNS server, choose the ‘Namecheap BasicDNS’ from NAMESERVERS field. After that click on the right logo to save the setting.

Next, navigate to Advanced DNS and add or update the/a ‘A’ record to google cloud external IP Address.

‘@’ represent your domain name.

Option 2: Use third party DNS Server

Image: We are using Google Cloud DNS as our DNS server.

To set up with third party DNS provider  such as Cloudflare(as DNS), google cloud DNS, AWS route 53 etc, select Custom DNS from ‘NAMESERVERS’ field and add nameservers. After that, click on the right logo to save the settings.

To complete your set up you have to add ‘A’ record from your DNS providers admin console.

Use Cloudflare as DNS server

Nowadays, Cloudflare is a very popular CDN provider around website owners. You may use Cloudflare as a CDN but what you don’t know about is, you can use Cloudflare as  a DNS provider.

Login to your Cloudflare account and then click on add a new site. After that  copy the NS records, and place the NS records on your domains registrar’s nameserver field.

Next, Click the DNS button from the to navigation menu.

NOW, Click on ‘Add record’, and select the Type as A, Name as @, on IPv4 address field place your server IP address. Then click the save button.

After that, add an another ‘A’ record for www subdomain.

Now Click on Orange cloud logo button (under ‘Proxy status’) to use Cloudflare as a DNS provider.

Leave a Comment

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