Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Prepare the source database for migration.
/ 20
Create a Database Migration Service connection profile.
/ 20
Create and start a continuous migration job.
/ 20
Confirm the data in Cloud SQL for PostgreSQL.
/ 20
Promote Cloud SQL to be a stand-alone instance for reading and writing data.
/ 20
Prepare the source database for migration.
/ 20
Create a Database Migration Service connection profile.
/ 20
Create and start a continuous migration job.
/ 20
Confirm the data in Cloud SQL for PostgreSQL.
/ 20
Promote Cloud SQL to be a stand-alone instance for reading and writing data.
/ 20
Database Migration Service provides options for one-time and continuous jobs to migrate data to Cloud SQL. It offers various connectivity methods, including IP allowlists, reverse SSH tunnels, VPC peering, and Private Service Connect interfaces. Learn more about connectivity options from the Configure connectivity Guide.
This lab focuses on migrating a stand-alone PostgreSQL database, hosted on a virtual machine, to Cloud SQL for PostgreSQL. The migration utilizes a continuous job from the Database Migration Service and employs VPC peering to establish connectivity.
Using Database Migration Service for database migration requires several preparatory steps on the source database:
pglogical extension: This extension needs to be installed on the source database.Once the setup is complete, you create and run the migration job. The migration process involves:
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the right is the Lab setup and access panel with the following:
Note that the lab timer is located near the top of the page, showing the remaining time.
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab setup and access panel.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab setup and access panel.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
Click Activate Cloud Shell at the top of the Google Cloud console.
Click through the following windows:
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Output:
gcloud, in Google Cloud, refer to the gcloud CLI overview guide.
The Database Migration API is required to manage the movement of database data through the Database Migration Service.
The Manage button is visible when the API is enabled.
The Service Networking API is required to configure Cloud SQL to support VPC Peering and connections over a private ip-address.
The Manage button is visible when the API is enabled.
To prepare the source database for the migration through the Database Migration Service, you upgrade the database with the pglogical extension and then create the database migration user.
To upgrade the database with the pglogical extension, you:
pglogical database extension.pglogical database extension to the postgres, orders and gmemegen_db databases on the stand-alone server.To create the database migration user, you create a migration_admin user (with Replication permissions) for database migration and then grant them the required permissions to schemata and relations.
In this section, you download and add the pglogical database extension to the orders and postgres databases on the postgresql-vm VM Instance.
In the Google Cloud console, on the Navigation menu (), click Compute Engine > VM instances.
In the postgresql-vm VM instance, click SSH.
If prompted, click Authorize.
In the new terminal window, install the pglogical database extension:
pglogical is a logical replication system implemented entirely as a PostgreSQL extension. Fully integrated, it requires no triggers or external programs. This alternative to physical replication is a highly efficient method of replicating data using a publish/subscribe model for selective replication.
pglogical extension) and restart the postgresql service:These files in pg_hba.conf add a rule to allow access to all hosts:
These commands in postgresql.conf set the minimal configuration for pglogical to listen on all addresses:
The above code snippets were appended to the relevant files and the PostgreSQL service restarted.
pglogical database extension to the postgres, orders and gmemegen_db databases:The output below lists the default postgresql databases, as well as the orders and gmemegen_db databases provided for this lab. You do not use the gmemegen_db database in this lab.
In this section you create a dedicated user to manage database migration.
In this section, you assign the necessary permissions to the migration_admin user to enable Database Migration Service to migrate your database.
pglogical schema and tables for the postgres database:pglogical schema and tables for the orders database:public schema and tables for the orders database:pglogical schema and tables for the gmemegen_db database:public schema and tables for the gmemegen_db database:The source databases are now prepared for migration. The permissions you have granted to the migration_admin user are all that is required for Database Migration Service to migrate the postgres, orders and gmemegen_db databases.
Make the migration_admin user the owner of the tables in the orders database, so that you can edit the source data later, when you test the migration.
Output
Click Check my progress to verify the objective.
In this task, you create a connection profile for the PostgreSQL source instance.
In this step, you identify the internal IP address of the source database instance that you migrate to Cloud SQL.
In the Google Cloud console, on the Navigation menu (), click Compute Engine > VM instances.
In the Instance list, locate postgresql-vm.
Copy the Internal IP (e.g., 10.128.0.2) to use to configure a connection profile in the next section.
A connection profile stores information about the source database instance (e.g., stand-alone PostgreSQL) and is used by the Database Migration Service to migrate data from the source to your destination Cloud SQL database instance. After you create a connection profile, it can be reused across migration jobs.
In this step you create a new connection profile for the PostgreSQL source instance.
In the Google Cloud console, on the Navigation menu (), click View all products. Under the Databases section, click Database migration > Connection profiles.
Click Create profile.
Specify the following fields and leave those remaining as their defaults:
| Field | Value |
|---|---|
| Source engine | PostgreSQL |
| Destination engine | Cloud SQL for PostgreSQL |
| Profile type | Source |
| Connection profile name | postgres-vm |
| Region | |
| Define connection configurations | Define |
| Hostname or IP address | the internal IP for the PostgreSQL source instance that you copied in the previous task (e.g., 10.128.0.2) |
| Port | 5432 |
| Username | migration_admin |
| Password | DMS_1s_cool! |
Click Save.
Click Create.
A new connection profile named postgres-vm shows in the Connections profile list.
Click Check my progress to verify the objective.
To create a new migration job, you must first specify the source database instance by using an existing connection profile. Next, you establish the destination database instance and set up the necessary connectivity between the source and destination instances.
In this task, you use the migration job interface to create a new Cloud SQL for PostgreSQL database instance and set it as the destination for the continuous migration job from the PostgreSQL source instance.
In this step you create a new continuous migration job.
In the console, on the Navigation menu (), click View all products. Under the Databases section, click Database Migration > Migration jobs.
Click Create migration job.
Specify the following fields and leave those remaining as their defaults:
| Field | Value |
|---|---|
| Migration job name | vm-to-cloudsql |
| Source database engine | PostgreSQL |
| Destination database engine | Cloud SQL for PostgreSQL |
| Destination region | |
| Migration job type | Continuous |
In this step you define the source instance for the migration.
Leave the defaults for the other settings.
In this step, you define the destination instance for the migration.
For Type of destination instance, select Existing instance.
For Select destination instance, select postgresql-cloudsql.
Click Select & continue.
If prompted to confirm, enter the instance name postgresql-cloudsql.
Click Confirm & continue.
In this step, you define the connectivity method for the migration.
For Connectivity method, select VPC peering.
For VPC, select default.
VPC peering is configured by Database Migration Service using the information provided for the VPC network (the default network in this example).
When you see an updated message that the destination instance was created, proceed to the next step.
In this step, you define the source instance for the migration.
For Databases to migrate, select All databases.
Click Save & continue.
In this step you edit the pg_hba.conf PostgreSQL configuration file to allow the Database Migration Service to access the stand-alone PostgreSQL database.
Get the allocated IP address range. In the console, on the Navigation menu (), click VPC networks and then right-click VPC network peering and open it in a new tab.
Click on the servicenetworking-googleapis-com entry and then click Effective routes view at the bottom.
From the dropdown for Network select default and for Region select
In the Destination IP range column , record the IP range (e.g. 10.107.176.0/24) next to peering-route-xxxxx... route to use in an upcoming step.
In the terminal session on the VM instance, edit the pg_hba.conf file as follows:
Replace the "all IP addresses" range (0.0.0.0/0) with the range recorded in the previous step.
Press CTRL+O, ENTER, CTRL+X to save the file and exit the nano editor.
Restart the PostgreSQL service to make the changes take effect. In the VM instance terminal session:
In this step, you test and start the migration job.
In the Database Migration Service tab you opened earlier, review the details of the migration job.
Click Test job.
After a successful test, click Create & start job.
If prompted to confirm, click Create & start.
In this step, you confirm that the continuous migration job is running.
In the Google Cloud console, on the Navigation menu (), click Database migration > Migration jobs.
Click the migration job vm-to-cloudsql to see the details page.
Review the migration job status.
When the job phase changes to CDC, proceed to the next task.
Click Check my progress to verify the objective.
In the Google Cloud console, on the Navigation menu (), click Cloud SQL.
Expand the instance ID called postgresql-cloudsql-master.
Click the instance postgresql-cloudsql (PostgreSQL read replica).
In the Replica instance menu, click Databases.
Notice that the databases called postgres, orders and gmemegen_db have been migrated to Cloud SQL.
In the Replica instance menu, click Overview.
Scroll down to the Connect to this instance section and click Open Cloud Shell.
The command to connect to PostgreSQL pre-populates in Cloud Shell:
Run the pre-populated command.
If prompted, click Authorize for the API.
When prompted for a password, which you previously set, enter:
You have now activated the PostgreSQL interactive console for the destination instance.
distribution_centers table:(Output)
You have now activated the PostgreSQL interactive console for the destination instance.
distribution_centers table:(Output)
Note that the new row added on the stand-alone orders database, is now present on the migrated database.
Click Check my progress to verify the objective.
In the Google Cloud console, on the Navigation menu (), click View all products. Under the Databases section, click Database Migration > Migration jobs.
Click the migration job name vm-to-cloudsql to see the details page.
Click Promote.
If prompted to confirm, click Promote.
When the promotion is complete, the status of the job updates to Completed.
Note that postgresql-cloudsql is now a stand-alone instance for reading and writing data.
Click Check my progress to verify the objective.
You configured a continuous Database Migration Service job to migrate databases from a PostgreSQL instance to Cloud SQL for PostgreSQL.
Learn more about data migration, Cloud SQL databases, and Database Migration Service:
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated on May 20, 2026
Lab Last Tested February 19, 2026
Copyright 2026 Google LLC. All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one
Complete this quick step to start your lab.