
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
Enable Backups on the Cloud SQL for PostgreSQL instance.
/ 40
Enable and run Point-in-Time Recovery.
/ 40
Confirm database is as it was at TIMESTAMP.
/ 20
Point-in-time recovery helps you recover an instance to a specific point in time. For example, if an error causes a loss of data, you can recover a database to its state before the error occurred. A point-in-time recovery always creates a new instance; you cannot perform a point-in-time recovery to an existing instance. The new instance inherits the settings of the source instance.
In this lab, you configure and test point-in-time recovery for a Cloud SQL for PostgreSQL instance.
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.
The content of this hands-on lab will be most applicable to PostgreSQL DBAs. This lab is designed to give professionals hands-on experience setting up and configuring Google Cloud resources to support PostgreSQL.
In this task you will enable scheduled backups on a Cloud SQL for PostgreSQL instance.
Click the Authorize button if prompted.
In Cloud Shell, get the current UTC time in 24 hour format:
In Cloud Shell, enter the following command to enable scheduled back-ups, replacing HH:MM
with a time that is earlier than the time that was displayed in the previous step.
For example if the date command shows that the current time is 14:25
you could replace HH:MM
with 13:25
, or even 12:00
. You must make sure it is a valid time in 24 hour format or you will receive an error saying the request was invalid.
You will see a response similar to the following showing that backups are set for 7 days, and run at 14:00 daily in this example:
In this task you will enable and configure point-in-time recovery on a Cloud SQL for PostgreSQL instance. A point-in-time recovery always creates a new instance; you cannot perform a point-in-time recovery to an existing instance. The new instance inherits the settings of the source instance.
In this step you will enable point-in-time recovery.
It will take a minute or two for this command to complete.
In this step you will add a row to the orders.distribution_centers
table in the database. After point-in-time recovery we will expect this row to be absent from the database.
In Cloud Console, on the Navigation menu (), click Databases > SQL and click on the Cloud SQL instance named
postgres-orders
.
In Cloud Console, in the Connect to this instance
section, click Open Cloud Shell. A command will be auto-populated to the Cloud Shell.
Run that command and enter the password supersecret!
when prompted. A psql session will start in Cloud Shell.
In psql, change to the orders
database:
When prompted, enter the password supersecret!
again.
In psql, get the row count of the distribution_centers
table:
Output:
You should wait for a few moments at this point to make sure that the changes you make in the next step occur after this timestamp.
orders.distribution_centers
table and get the new COUNT, run:Output:
In this step you will make a clone of the postgres-orders
Cloud SQL instance at a specific point in time.
You must replace the TIMESTAMP placeholder with the exact timestamp displayed by the date
command you used earlier in the second Cloud Shell tab.
This TIMESTAMP must be UTC timezone, RFC 3339 format, for example, '2021-11-01 15:00:00'. The TIMESTAMP indicates the time to which you want to recover the state of the database. It should be enclosed in single quotes. The alternate RFC3339 variant is also supported: '2021-11-01T15:00:00.000Z'.
It could take 10 minutes or more for the replica to be created and ready for use. In the mean time, continue with the next task.
In this task you will confirm that a row of data that was added to the original database after the point-in-time recovery timestamp is not in the cloned database.
postgres-orders-pitr
.Now you will have to wait for the replica to come online.
In Cloud Console, in the Connect to this instance
section, click Open Cloud Shell. A command will be auto-populated to the Cloud Shell.
Run that command and enter the password supersecret!
when prompted. A psql session will start in Cloud Shell.
In psql, change to the orders
database:
When prompted, enter the password supersecret!
again.
In psql, get the row count of the distribution_centers
table:
Output:
You will see that the distribution_centers
table in the new Cloud SQL for PostgreSQL instance has the 10 rows that it had on the source instance at the point-in-time of cloning. If your query returns 11 rows check that you have connected to the replica instance and not the original.
In this lab, you configured and tested point-in-time recovery for a Cloud SQL for PostgreSQL instance.
...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 April 23, 2024
Lab Last Tested Dececember 06, 2023
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