Skip to content
Follow
CMS

How to Migrate a Website to Google Cloud Without Downtime

Richard
Written by
Richard
Jan 2, 2022 Updated Sep 15, 2026 11 min read
establish ssh connection to vm instances
establish ssh connection to vm instances

Website migration to Google Cloud Platform (GCP) moves your site to Google’s servers while keeping your pages online so visitors never see a broken link or error page. GCP is a suite of cloud computing services that hosts web apps and databases on the same network Google uses for its own products.

Advertisement

Completing this move with zero downtime takes about 2 to 4 hours of setup before you switch your domain name over. You set up a new virtual server, copy your files and database, test everything works, and then point your web address to the new location.

⚡ Quick Answer

Prepare your Google Cloud environment, copy your website files and databases, and then update your DNS records. This process ensures visitors are seamlessly directed to your new site on Google Cloud without interruption.

Advertisement

Taking inventory of a Linux server before migration

To take inventory of a Linux server before migration, you need to record your exact web server software, database version, and PHP packages. Run commands like apache2 -v or nginx -v, check your mysql version, and list installed PHP modules. Matching these details on your new Google Cloud server prevents compatibility errors and keeps your website running properly after you migrate website to Google Cloud.

Here’s what you’ll need to gather from your current server:

  • Web server and version number
  • Database server and version number
  • PHP and related modules
  • Other servers and services and how they’re configured
* **Web server and version number** * **Database server and version number** * **PHP and related modules** * **Other servers and services, along with their configurations** %%/UL17%%

An Apache web server’s version on Ubuntu Linux can be found using specific commands. This version information is crucial for ensuring compatibility with Google Cloud services during migration.

The guide offers detailed version checks and steps to install a specific Apache version, ensuring you have the correct software for your website migration to Google Cloud.

Advertisement

How to check and install specific Apache versions on Ubuntu Linux

Nginx web server version detection on Ubuntu Linux requires specific commands. You can determine your Nginx version by running the command `nginx -v`. This command will display the exact version number, for example, Nginx version 1.18.0.

This guide offers detailed version checks and installation steps for a specific Nginx version, ensuring you can verify the correct software for your migration.

How to check and install specific Nginx versions on Ubuntu Linux

Advertisement

To check what PHP version is installed and how to install a specific one on Ubuntu Linux, see this guide.

How to check and install specific PHP versions on Ubuntu Linux

Whether you're running MySQL or MariaDB, the guide below shows you how to determine which version runs on Ubuntu Linux.

How to find what version of MySQL or MariaDB runs on Ubuntu Linux

Advertisement

How to set up and connect to your Google Cloud server

To set up and connect to your Google Cloud server, create a virtual machine instance using Compute Engine in the Google Cloud Console. Open your project dashboard, find your virtual machine instance in the list, and click the SSH button next to it. This opens a secure browser window where you can run commands directly on your new server to migrate website to Google Cloud without needing extra SSH keys.

Your Google Cloud server (called Compute Engine) lets you connect via SSH directly from your browser window to your virtual machine (VM) instance within the Google Cloud Console.

SSH from the browser supports the following web browsers:

  • Web browsers
    • The latest version of Google Chrome
    • Firefox
    • Microsoft Edge
    • Microsoft Internet Explorer 11 and later
    • Safari 8 and later. Note that Safari is not supported in private browser mode.
    * Google Chrome (latest version) * Firefox * Microsoft Edge * Microsoft Internet Explorer 11 and later * Safari 8 and later (Note: Safari is not supported in private browser mode.) %%/UL18%%
  • Virtual machine configurations
    • All Linux VM images are natively available in Google Cloud.

All Linux VM (virtual machine) images are natively available in Google Cloud without any extra software or browser extensions. Log in to Google Cloud Console and go to Menu ==> Compute Engine ==> VM instances.

Advertisement

In the list of virtual machine instances, click SSH in the row of the instance you want to connect to.

establish ssh connection to vm instances
establish ssh connection to vm instances

Alternatively, you can open an SSH connection to an instance by clicking its name and SSH from the instance details page.

An SSH terminal window with the Ubuntu Linux instance created in the series's second post will open.

You should now be able to run commands in Ubuntu Linux created on the Google Cloud server.

Advertisement
connect to google cloud instance host
connect to google cloud instance host

Install LAMP or LEMP on the new server before migration

To install LAMP or LEMP on the new server before migration, connect to your virtual machine via SSH and run your package manager to install Apache or Nginx, MySQL, and PHP. Make sure the software versions match your old server exactly so your website files and databases run correctly. Getting this stack ready is a crucial step when you migrate website to Google Cloud.

Your goal is to ensure your new Google server has the same servers and packages as your current one. We've listed some helpful posts that you can use to install Apache, Nginx, MySQL, MariaDB, or PHP.

Some other posts that you may want to use when installing LAMP or LEMP on Ubuntu Linux.

* How to check and install specific Apache versions on Ubuntu Linux * How to check and install specific Nginx versions on Ubuntu Linux * How to check and install specific PHP versions on Ubuntu Linux * How to find what version of MySQL or MariaDB runs on Ubuntu Linux %%/UL20%%

You can use the posts above to install the same servers and packages you have installed on your current server. However, if you install specific packages on your new server, use the identical posts mentioned above.

Advertisement

Once all the packages are installed, you can transfer content from your current server to the new one.

Configure your new Google server similar to your current server

To configure your new Google server similar to your current server, copy your web server configuration files, folder paths, and Virtual Host or Server block settings. Check file permissions and PHP configuration limits to match your old environment. Doing this prevents broken links and missing features when you migrate website to Google Cloud.

Ensure the web server (Apache or Nginx) settings are on old and new servers, including the same directory structure and Virtual Host or Server block content.

  • Apache directory: /etc/apache2/
  • Nginx directory: /etc/nginx/
* Set up Apache virtual hosts * Set up Nginx server blocks %%/UL21%%

Your PHP configuration should also be identical to your current server's PHP settings. Use the post above to install a specific PHP version and all the modules on your current server.

  • PHP directory: /etc/php/
* Install specific PHP versions * Install PHP modules %%/UL22%%

Your MySQL or MariaDB configurations should also mimic your current server. Validate each file, directory, and other data to ensure your new server is no different from your current server before migration.

  • MySQL / MariaDB directory: /etc/mysql/
* Configure MySQL * Configure MariaDB %%/UL23%%

Once you have that done, you can continue with the migration process.

Back up current server data and database before migration

To back up current server data and database before migration, stop incoming website traffic to freeze your data, then compress your website files into an archive. Export your MySQL or MariaDB database using mysqldump to create a fresh SQL file. Store both backups safely on your local computer before you migrate website to Google Cloud.

Back up your website files and database before moving anything to the new server.

⚠️WarningBefore backing up your current server, it's important to stop all changes.

Before backing up your current server, it's important to stop all changes. You don't want new updates to be added after the backup is complete.

To back up your website content, log on to your server via SSH if you have access. Once on your current server SSH console, run the commands below to back up your website content, usually at this location: /var/www/html/.

When you run the commands below, a backed-up file named current-server-backup.tar will be created with your website content.

Backing up your database content is the next crucial step. You must use the root account, or an account with full access to the specific database you wish to back up, to perform this operation.

To back up all databases on the server, run the commands below:

A file named all_databases_backup.sql, which contains a complete copy of your database, should be created in the current working directory. This backup file ensures that all your database information is safely stored before you begin the migration process, preventing data loss.

You should now have two files: current-server-backup.tar and all_database_backup.sql.

Copy the current server's content to the Google Cloud server

At this point, you should be ready to copy the current server's content over to your new server. There are many ways to get the tar and SQL data files to the new server.

You can use the rsync command from the new server by SSHing into it and using a command similar to that shown below (changing the host names as needed).

While connected to your Google Cloud console, run the commands below to connect to your current server and copy over the backed-up content.

You can use the Secure Copy Protocol (SCP) to copy your website files securely. The SCP syntax for this task looks like scp -r /path/to/local/directory user@remote_host:/path/to/remote/directory, which allows you to transfer entire directories at once.

scp user@old-server.com:/home/<username>/all_database_backup.sql /home/username/
scp user@old-server.com:/home/<username>/current-server-backup.tar /home/username/
```bash scp -r /var/www/html/ user@your_current_server_ip:/var/www/html/ scp all_databases_backup.sql user@your_current_server_ip:/home/user/ ``` %%/PRE12%%

If you can't get the files using SSH, then you can use the wget command to download the files to your new Google Cloud server.

You must copy the files to the current server's web server root directory to be able to use the commands below.

cd ~
wget http://old-web-site.com/all_database_backup.sql
wget http://old-web-site.com/current-server-backup.tar
```bash wget https://your-current-server.com/path/to/current-server-backup.tar wget https://your-current-server.com/path/to/all_databases_backup.sql ``` %%/PRE13%%

Once the files are copied to your new server, continue to extract them below and import the database content into your database server.

Restore the current server's content to the Google Cloud server

To restore the current server's content to the Google Cloud server, upload your backup archive and database file to the new virtual machine. Extract your website files into the correct web root directory and import your SQL database using the command line. This populates your new environment with your live site data when you migrate website to Google Cloud.

tar -xvf current-server-content.tar
sudo cp -rf /var/www/html/ /var/www/html/
```bash tar -xvf current-server-backup.tar -C /var/www/html/ ``` %%/PRE14%%

Next, run the commands below to import the database content to your servers.

sudo mysql -u root -p < all_database_backup.sql
```bash mysql -u root -p < all_databases_backup.sql ``` %%/PRE15%%

At this point, your Google server should have the current servers and database content. Next, run the commands below to set up the current permissions to match the server.

Validate that all configurations on your current server match your new Google Cloud server. Once all have been validated, restart your web server.

sudo systemctl restart nginx
sudo systemctl restart apache2
```bash sudo systemctl restart apache2 # or sudo systemctl restart nginx ``` %%/PRE16%%

If you get an error, make sure to resolve it.

Update your DNS and point your domain to your new Google server IP address

To update your DNS and point your domain to your new Google server IP address, log in to your domain registrar or DNS hosting provider. Find your DNS management page and change the A record value to point to your new Google Cloud server's public IP address. Wait for the DNS changes to spread globally to finish your plan to migrate website to Google Cloud.

Once your local test is successful, log in to your DNS provider portal and update the DNS A record to point to your new server IP address.

If everything works, you can continue fine-tuning your new server to ensure everything is configured correctly.

That should do it!

Conclusion:

This guide has walked you through migrating a website to a Google Cloud server. Please use the comment form below if you find any errors above or have something to add.

Can I host my website on Google Cloud for free?

How do I start hosting my website or web app on Google Cloud?

Use our free trial to start hosting your website or web app with any Google Cloud product. Watch an overview on how to build and host a website on Google Cloud. Learn how to serve or migrate a website or choose an option in our technical article.

Is Google Cloud good for hosting websites?

Why is Google Cloud good for hosting websites?

Google Cloud is good for hosting websites because it offers more flexibility and scalability than normal web hosting, keeping your site online reliably and making it a safe choice for businesses.

```

Was this guide helpful?

📬 Get new Windows tips in your inbox
One email when we publish something worth your time. No spam, unsubscribe anytime.
Tags: #Ubuntu Linux
Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

3170 articles → Twitter
Advertisement

📚 Related Tutorials

How to Install PHP on Google Cloud Server
CMS How to Install PHP on Google Cloud Server
How to Create your Website on Google Cloud Server
Ubuntu Linux How to Create your Website on Google Cloud Server
How to Backup and Restore Microsoft Edge
Browsers How to Backup and Restore Microsoft Edge
Install MySQL and MariaDB on Ubuntu: A Step-by-Step Guide
Ubuntu Linux Install MySQL and MariaDB on Ubuntu: A Step-by-Step Guide

No comments yet — be the first to share your thoughts!

Leave a Comment

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