gcp-postgres-restore marketplace blueprint restores a Cloud SQL for PostgreSQL instance to a point in time and writes a JSON record of every run to a Cloud Storage bucket. Use it to run restore tests and keep evidence of them.
Each run restores the source into a new instance named <source>-restore-<random> and checks it. The source instance is only read.
A run starts only when you trigger the job. There is no schedule, and a failed run is never retried.
The blueprint works only in GCP environments. In AWS and Azure environments it creates nothing.
Prerequisites
- A GCP environment.
- A Cloud SQL for PostgreSQL instance in the environment’s project, with automated backups and point-in-time recovery turned on. The Postgres marketplace blueprint turns both on by default and keeps 7 days of transaction logs, so you can restore to any point in the last 7 days.
Install the blueprint
sourceInstance is the name of the instance to restore. Take it from the Postgres installation’s instanceName output. checkDatabases is a comma-separated list of databases that must exist in the restored copy. Leave it empty to skip that check. Leave accessUntil unset: the job has no Cloud SQL admin access until you open it for a run.
The installation creates:
- A job installation with the same name, in the
compliancenamespace. - An evidence bucket named
postgres-restore-evidence-<random>, with object versioning and deletion protection. The installation’sevidenceBucketNameoutput holds the full name. - Workload Identity access for the job. It gets Cloud SQL admin only while
accessUntilis set and in the future, through an IAM condition that also limits it to the source instance and instances named<source>-restore-*. It always has read-only Cloud SQL access to the project so it can follow operations. On the evidence bucket it can create objects but not read, replace or delete them.
Run a restore test
-
Open access for the run: set
accessUntilon the installation to a UTC time about 2 hours after you deploy it, and deploy it. The job only needs access to start the restore; once Cloud SQL accepts the request, the restore finishes even if access lapses. Two hours leaves time for the deploy, for the grant to apply, which usually takes a few minutes, and for a retry or two. If the change waits for review before it deploys, count from when it will deploy, or update the time just before. To get the time 2 hours from now: -
Trigger the job. Open the
postgres-restoreinstallation and click Run Now in the Actions menu, or run:WithrestoreTimeempty, the run restores to the latest recoverable time. To restore to an earlier point, setrestoreTimeon the installation first, in UTC and ending inZ, for example2026-01-01T12:00:00Z. - Wait for the job to finish. On a small instance the restore takes 20 to 40 minutes. The job stops after 55 minutes.
-
Read the run’s record:
-
Check the data, if you need more than the job’s checks. The job confirms only that the copy is running and has the databases in
checkDatabases; it doesn’t read your data. The copy has the source’s databases, users and passwords as ofrestoreTime, at its own IP addresses. -
Delete the copy with the command in the record’s
cleanupfield. The copy keeps running, and costs about as much as the source, until you delete it. -
Clear
accessUntiland deploy, which removes the grant. It grants nothing afteraccessUntileither way.
restore with a permission error right after you deployed accessUntil, the grant hasn’t applied yet. Wait a few minutes and trigger the job again.
The run record
The job writes one record per run toruns/<source>/<runId>.json, including runs that fail. If the record can’t be written, the run fails.
Limits
- GCP only.
- A run stops after 55 minutes. A large instance can take longer than that to restore.
restoreTimemust fall inside the source’s point-in-time recovery window.- Copies keep running until you delete them.
- A run can start a restore only before
accessUntil. - The evidence bucket has no retention lock. Anyone with Cloud Storage admin rights in the project can delete records.