Stay organized with collections Save and categorize content based on your preferences.
This page describes how to migrate a Cloud SQL for PostgreSQL instance by copying a Cloud SQL backup into an AlloyDB for PostgreSQL free trial cluster. Copying a Cloud SQL backup into an AlloyDB cluster enables you to quickly load data into Cloud SQL for PostgreSQL, which lets you evaluate or migrate into AlloyDB.
This page assumes familiarity with Cloud SQL. If you're new to AlloyDB, see the AlloyDB overview.
To learn how to migrate your data from Cloud SQL to AlloyDB using continuous data replication, see Database Migration Service for PostgreSQL to AlloyDB.
The following aren't supported:
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.Make sure that billing is enabled for your Google Cloud project.
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.Make sure that billing is enabled for your Google Cloud project.
Enable the AlloyDB, Compute Engine, and Service Networking APIs.
To get the permissions that you need to copy a Cloud SQL for PostgreSQL backup into an AlloyDB cluster, grant yourself the following IAM roles on your project:
roles/cloudsql.viewer
) or any custom role that includes the cloudsql.backupRuns.export
permission.roles/alloydb.admin
)Copying a Cloud SQL backup into an AlloyDB free trial cluster restores the backup to the same version of PostgreSQL on AlloyDB, for example, a PostgreSQL 14 Cloud SQL backup restores to a PostgreSQL 14 free trial cluster. Keep in mind that extension versions and PostgreSQL minor versions might be different.
Copying a backup from Cloud SQL only supports the configuration of those items supported in the AlloyDB free trial cluster.
Note: You can't copy a backup if it's greater than 1TB.To copy a Cloud SQL backup into an AlloyDB free trial cluster, follow these steps:
ConsoleAfter the operation completes, a primary instance is automatically created. You see a new AlloyDB cluster with the data that is copied from the Cloud SQL for PostgreSQL backup that you selected.
When you copy a Cloud SQL for PostgreSQL backup into an AlloyDB cluster, database flags and resource level permissions aren't automatically migrated. After the copy is complete, you must set up these flags and permissions manually.
You can check which database flags in Cloud SQL for PostgreSQL are supported in AlloyDB in the Create your free cluster page.
gcloudTo use the gcloud CLI, you can install and initialize the gcloud CLI, or you can use Cloud Shell.
gcloud beta alloydb clusters migrate-cloud-sql
command:gcloud beta alloydb clusters migrate-cloud-sql CLUSTER_ID
--cluster-id=CLUSTER_ID
\
--cloud-sql-backup-id=CLOUD_SQL_BACKUP_ID
\
--cloud-sql-instance-id=CLOUD_SQL_INSTANCE_ID
\
--cloud-sql-project-id=CLOUD_SQL_PROJECT_ID
--password=PASSWORD
\
--region=REGION
\
--database-version=DATABASE_VERSION
\
--subscription-type=TRIAL
Replace the following:
CLUSTER
: Cloud SQL for PostgreSQL cluster ID.CLOUD_SQL_BACKUP_ID
: CloudSQL backup ID to migrate from. This must be the backup ID.CLOUD_SQL_INSTANCE_ID
: CloudSQL instance ID to migrate from. This must be the instance ID.CLOUD_SQL_PROJECT_ID
: CloudSQL project to migrate from. This must be the project ID.PASSWORD
: initial PostgreSQL user password to set up during cluster creation.REGION
: location, for example, asia-east1
or us-east1
. See the full list of regions at regional locations.DATABASE_VERSION
: database version of the cluster. This must be one of: POSTGRES_14
, POSTGRES_15
, or POSTGRES_16
. The database version must be same as the version of the Cloud SQL backup.SUBSCRIPTION_TYPE
: subscription type of the cluster. This must be one of: STANDARD
or TRIAL
.gcloud beta alloydb operations describe
command to confirm the status of the backup operation:gcloud beta alloydb operations describe OPERATION_ID \ --region=REGION_ID \ --project=PROJECT_ID
Replace the following:
OPERATION_ID
: the name of the AlloyDB operation.REGION_ID
: the region in which the AlloyDB cluster is deployed.PROJECT_ID
: the project ID.gcloud alloydb instances create
command to create a primary instance.backupsRuns.list
method:GET "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_ID/backupRuns"
Replace the following:
PROJECT_ID
: the project ID.INSTANCE_ID
: the instance ID.{ "kind": string, "items": [ { object (BackupRun) } ], "nextPageToken": string }
To send your request, use one of these options:
curl (Linux, macOS, or Cloud Shell)The following command assumes that you signed into the gcloud CLI
with your user account by running gcloud init
or gcloud auth login
, or by using Cloud Shell
, which automatically signs you into the gcloud CLI
.
You can check the active account by running gcloud auth list
.
Save the request body in a file named request.json
and execute the following command:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ "https://sqladmin.googleapis.com//sql/v1beta4/projects/PROJECT_ID/instances/INSTANCE_ID/backupRuns"PowerShell (Windows)
The following command assumes that you signed into the gcloud CLI
with your user account by running gcloud init
or gcloud auth login
, or by using Cloud Shell
, which automatically signs you into the gcloud CLI
.
You can check the active account by running gcloud auth list
.
Save the request body in a file named request.json
and execute the following command:
$cred = gcloud auth print-access-token $headers = @{ "Authorization" = "Bearer $cred" } Invoke-WebRequest ` -Method GET ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -Uri "https://sqladmin.googleapis.com//sql/v1beta4/projects/PROJECT_ID/instances/INSTANCE_ID/backupRuns"|Select-Object -Expand Content
You receive a JSON response similar to the following:
ResponseIf successful, the response body contains a list of BackupRun
.
"id": string,
.POST https://alloydb.googleapis.com/v1beta/projects/PROJECT_ID/locations/REGION/clusters:restoreFromCloudSQL
Replace the following:
PROJECT_ID
: the project ID.REGION
: the region in which the AlloyDB cluster is deployed.{ "clusterId": string, "cluster": { "databaseVersion": "POSTGRES_14/POSTGRES_15/POSTGRES_16", "subscriptionType": "TRIAL" }, // Union field source can be only one of the following: "cloudsqlBackupRunSource": { object (CloudSQLBackupRunSource) } // End of list of possible types for union field source. }
To send your request, use one of these options:
curl (Linux, macOS, or Cloud Shell)The following command assumes that you signed into the gcloud CLI
with your user account by running gcloud init
or gcloud auth login
, or by using Cloud Shell
, which automatically signs you into the gcloud CLI
.
You can check the active account by running gcloud auth list
.
Save the request body in a file named request.json
and execute the following command:
curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ -d @request.json \ "https://alloydb.googleapis.com/v1beta/projects/PROJECT_ID/locations/REGION/clusters:restoreFromCloudSQL"PowerShell (Windows)
The following command assumes that you signed into the gcloud CLI
with your user account by running gcloud init
or gcloudauth login
, or by using Cloud Shell
, which automatically signs you into the gcloud CLI
.
You can check the active account by running gcloud auth list
.
Save the request body in a file named request.json
and execute the following command:
$cred = gcloud auth print-access-token $headers = @{ "Authorization" = "Bearer $cred" } Invoke-WebRequest ` -Method POST ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -InFile request.json ` -Uri "https://alloydb.googleapis.com/v1beta/projects/PROJECT_ID/locations/REGION/clusters:restoreFromCloudSQL"|Select-Object -Expand Content
You receive a JSON response similar to the following:
ResponseIf successful, the response body contains an instance of Operation
.
A new cluster is created in the specified project and location, with a volume restored from the backup pointed in the CloudSQLBackupRunSource message.
READY
state, create the primary instance by calling the projects.locationsinstances.create
method:POST https://alloydb.googleapis.com/v1beta/{parent=projects/PROJECT_ID/locations/REGION/clusters/CLUSTER_ID}/instances
Replace the following:
PROJECT_ID
: the project ID.REGION
: the region in which the AlloyDB cluster is deployed.CLUSTER_ID
: the cluster ID.{ "instanceId": "string", "instance": { "object": "Instance" } }
The request body contains an instance of Instance
.
To send your request, use one of these options:
curl (Linux, macOS, or Cloud Shell)The following command assumes that you signed into the gcloud CLI
with your user account by running gcloud init
or gcloud auth login
, or by using Cloud Shell
, which automatically signs you into the gcloud CLI
.
You can check the active account by running gcloud auth list
.
Save the request body in a file named request.json
and execute the following command:
curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ -d @request.json \ "https://alloydb.googleapis.com/v1beta/projects/PROJECT_ID/locations/REGION/clusters/CLUSTER_ID/instances"PowerShell (Windows)
The following command assumes that you signed into the gcloud CLI
with your user account by running gcloud init
or gcloud auth login
, or by using Cloud Shell
, which automatically signs you into the gcloud CLI
.
You can check the active account by running gcloud auth list
.
Save the request body in a file named request.json
and execute the following command:
$cred = gcloud auth print-access-token $headers = @{ "Authorization" = "Bearer $cred" } Invoke-WebRequest ` -Method POST ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -InFile request.json ` -Uri "https://alloydb.googleapis.com/v1beta/projects/PROJECT_ID/locations/REGION/clusters/CLUSTER_ID/instances"|Select-Object -Expand Content
You receive a JSON response similar to the following:
ResponseIf successful, the response body contains a newly created instance of Operation
.
READY
state, connect to the instance and access the restored data from the Cloud SQL snapshot.Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-02 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-02 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4