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
Create a connection profile for the PostgreSQL source instance
/ 50
Test the continuous migration of data
/ 50
In Google Cloud, you can use Database Migration Service to migrate PostgreSQL databases to AlloyDB for PostgreSQL. To do this, AlloyDB requires the use of private services access. In this lab environment, you implement this access as a VPC peering connection between your VPC network and the underlying Google Cloud VPC network where your AlloyDB resources reside. Then, you migrate a stand-alone PostgreSQL database (running on a virtual machine) to AlloyDB for PostgreSQL using a continuous Database Migration Service job with VPC peering for connectivity.
To migrate a database using Database Migration Service, certain steps must be performed to prepare the source database. These preparatory tasks, most importantly setting up the pglogical package, have already been completed for you on the source environment.
After you create and run the migration job, you confirm that an initial copy of your database has been successfully migrated to your AlloyDB for PostgreSQL instance. You also explore how continuous migration jobs apply data updates from your source database to your AlloyDB for PostgreSQL instance.
In this lab, you learn how to configure a continuous Database Migration Service job to migrate databases from a PostgreSQL instance to AlloyDB for PostgreSQL. This 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 left is the Lab Details pane with the following:
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 Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details pane.
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.
In this task, you connect and verify data in the postgres database on the pg14-source VM instance.
On the Navigation menu (), under Compute Engine click VM instances.
For the instance named pg14-source, in the Connect column, click SSH to open a terminal window.
Use the following command to launch the PostgreSQL (psql) client:
The psql terminal prompt opens. It looks similar to what's shown below:
The source table row counts are as follows:
| Name | Rows |
|---|---|
| countries | 25 |
| departments | 27 |
| employees | 107 |
| jobs | 19 |
| locations | 23 |
| regions | 4 |
Type \q to exit the psql client.
Type exit to close the terminal window.
In this task, you create a connection profile for the PostgreSQL source instance.
You need the internal IP address of the source database instance to migrate the database to AlloyDB.
Still on the VM instances page, locate the pg14-source instance.
Record the Internal IP (e.g., 10.128.15.208).
A connection profile stores information about the source database instance (e.g., stand-alone PostgreSQL). Database Migration Service uses the connection profile to migrate data from the source database to the destination database. After you create a connection profile, you can reused it 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.
In the Databases category, click Database Migration.
In the left pane, click Connection profiles, and then click Create profile.
Set the following fields as shown below. Leave all other fields as the defaults.
| Fields | Value |
|---|---|
| Source engine | PostgreSQL |
| Destination engine | Cloud SQL for PostgreSQL |
| Choose the profile type to create | Source |
| Connection profile name | pg14-source |
| Region | |
| PostgreSQL to PostgreSQL | Click Define |
| PostgreSQL to PostgreSQL | Enter the internal IP for the PostgreSQL source instance that you previously recorded (e.g., 10.128.15.208) |
| Port | 5432 |
| Username | postgres |
| Password | Change3Me |
Click Save
Click Create.
A new connection profile named pg14-source shows in the Connections profile list.
Click Check my progress to verify the objective.
When you create a new migration job, you first define the source database instance using a previously created connection profile. You then create a new destination database instance and configure connectivity between the source and destination instances.
In this task, you use the migration job interface to create a new AlloyDB for PostgreSQL cluster 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.
Still in the Database migration page, click Migration jobs in the left pane.
Click Create migration job.
| Field | Value |
|---|---|
| Migration job name | postgres-to-alloydb |
| Source database engine | PostgreSQL |
| Destination database engine | AlloyDB for PostgreSQL |
| Destination region |
For Select source connection profile, select the pg14-source connection profile you created a few steps ago.
Click Save & continue.
For Type of destination cluster, select Existing cluster.
For Cluster ID, select alloydb-target-cluster.
Click Select & continue.
When prompted to confirm, type alloydb-target-cluster to confirm, then click Confirm & continue.
For Connectivity method, select VPC peering.
Click Configure & continue.
Set Databases to migrate to All databases.
Click Save & continue.
The Database Migration Service wizard is now on the Test and create your migration job step.
Click Test job.
After a successful test, click Create & start job.
The postgres-to-alloydb details page opens.
The cluster is named alloydb-target-cluster and the instance is named alloydb-target-instance.
Click alloydb-target-cluster, and then in the left pane, click Connectivity.
Record the Private IP address, for example, 10.24.0.2.
Notice that if you click Copy to clipboard to copy the Private IP address, the port number is included, for example, 10.24.0.2:5432. Record only the IP address, for example, 10.24.0.2 to use in a later step.
On the Navigation menu (), under Compute Engine click VM instances.
For the alloydb-client instance, click SSH to open a terminal window.
Set the following environment variable, replacing [ALLOYDB_ADDRESS] with the Private IP address of the AlloyDB instance (for example, 10.24.0.2):
The target table row counts are as follows:
| Name | Rows |
|---|---|
| countries | 25 |
| departments | 27 |
| employees | 107 |
| jobs | 19 |
| locations | 23 |
| regions | 4 |
Leave this terminal window open to use in the next section.
Because the Database Migration Service job is set in a continuous update configuration, any updates you make on the source instance are applied to the AlloyDB target.
Return to Google Cloud console.
For the pg14-source instance, click SSH to open a terminal window.
Use the following command to launch the PostgreSQL (psql) client:
You have now successfully migrated a stand-alone PostgreSQL database (running on a virtual machine) to AlloyDB for PostgreSQL using a continuous Database Migration Service job.
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 December 15, 2025
Lab Last Tested November 24, 2025
Copyright 2025 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