Restore an instance

This page describes how to restore your instance from a backup.

For information, best practices, and requirements for restore operations, see Overview of restoring an instance.

Restore from an on-demand or automated backup

You can use an on-demand or automated backup for the following scenarios:

  • Restore to a different instance in the same project
  • Restore to the same instance from where the backup is taken
  • Restore to a different instance in a different project or region

If you have point-in-time recovery (PITR) enabled, then you can recover your instance to a specific point in time, based on the log retention settings for your instance.

Restoring an instance from a backup requires that the backup and target instances are in the same time zone.

Restore to a different instance

When you restore data from a backup to a different instance, you update the data on the target instance to the state of the source instance when you took the backup. For more information, see General tips about performing a restore and Tips and requirements for restoring to a different instance.

If you need a list of backups for the project and can't view them on the instance overview page due to an outage, you can use the backupRuns.list API with a wildcard (-). The wildcard option retrieves a list of all backups across all instances in the project. For more information, see Viewing backups during an outage.

Console

  1. In the Google Cloud console, go to the Cloud SQL Instances page.

    Go to Cloud SQL Instances

  2. If the target instance has any read replicas, then use the more actions menu More actions icon. to delete them.
  3. To open the Overview page of an instance, click the instance name.
  4. From the SQL navigation menu, select Backups.
  5. Find the backup that you want to restore from, and then click Restore.
  6. In the Restore an instance from a backup page, confirm that you selected the correct backup in Review backup details.
  7. In Choose restore destination, select Overwrite an existing instance.
  8. From the Instance to be overwritten menu, select the instance you want to use for the restore. The instance that you select and all of its data are overwritten.
  9. To confirm your selection, enter the name of the instance to be overwritten in the Destination instance ID field.
  10. To start the restore process, click Restore.
  11. To check the status of the restore operation, go to the Operations page for the instance.
  12. After the restore operation completes, recreate any replicas that you deleted in this procedure.

gcloud

  1. To determine if the target instance has any read replicas, use the gcloud sql instances describe command:
    gcloud sql instances describe TARGET_INSTANCE_NAME

    Note any instances that are listed in the replicaNames column.

  2. To delete all replicas, use the gcloud sql instances delete command:
    gcloud sql instances delete REPLICA_NAME

    Repeat for each replica.

  3. To list the backups for the source instance, use the gcloud sql backups list command:
    gcloud sql backups list \
    --instance SOURCE_INSTANCE_NAME
  4. Find the backup that you want to use and record its ID value.
  5. To restore the target instance from the backup, use the gcloud sql backups restore command:
    gcloud sql backups restore BACKUP_ID \
    --restore-instance=TARGET_INSTANCE_NAME \
    --backup-instance=SOURCE_INSTANCE_NAME
  6. After the restore operation completes, recreate any replicas that you deleted in this procedure.

REST v1

  1. To determine if the instance has any read replicas and to get the IDs of these replicas, list all replicas for the target instance.

    Before using any of the request data, make the following replacements:

    • PROJECT_ID: the project ID
    • INSTANCE_ID: the instance ID

    HTTP method and URL:

    GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_ID?fields=replicaNames

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

  2. Delete all replicas.

    Before using any of the request data, make the following replacements:

    • PROJECT_ID: the project ID
    • REPLICA_ID: the replica ID

    HTTP method and URL:

    DELETE https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/REPLICA_ID

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

    Repeat for each replica.

  3. To get the ID of the backup that you want to use, list the backups for the source instance.

    Before using any of the request data, make the following replacements:

    • project-id: The project ID
    • instance-id: The instance ID

    HTTP method and URL:

    GET https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id/backupRuns

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

    -OR-

    If your instance is in a region that's having an outage, then list all of the backups in a project

    Before using any of the request data, make the following replacements:

    • PROJECT_ID: the project ID
    • INSTANCE_ID: the instance ID, or - for a list of all backups in the project

    HTTP method and URL:

    GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/-/backupRuns

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

    Find the backup for the instance that you need to restore.
  4. Restore the target instance from the backup.

    Before using any of the request data, make the following replacements:

    • project-id: The project ID
    • target-instance-id: The target instance ID
    • source-instance-id: The source instance ID
    • backup-id The backup ID

    HTTP method and URL:

    POST https://sqladmin.googleapis.com/v1/projects/project-id/instances/target-instance-id/restoreBackup

    Request JSON body:

    {
      "restoreBackupContext":
      {
        "backupRunId": backup-id,
        "instanceId": "source-instance-id"
      }
    }
    

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

  5. After the restore operation completes, recreate any replicas that you deleted in this procedure.

REST v1beta4

  1. To determine if the instance has any read replicas and to get the IDs of these replicas, list all replicas for the target instance.

    Before using any of the request data, make the following replacements:

    • PROJECT_ID: the project ID
    • INSTANCE_ID: the instance ID

    HTTP method and URL:

    GET https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/INSTANCE_ID?fields=replicaNames

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

  2. Delete all replicas.

    Before using any of the request data, make the following replacements:

    • PROJECT_ID: the project ID
    • REPLICA_ID: the replica ID

    HTTP method and URL:

    DELETE https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/REPLICA_ID

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

    Repeat for each replica.

  3. To get the ID of the backup that you want to use, list the backups for the source instance.

    Before using any of the request data, make the following replacements:

    • project-id: The project ID
    • instance-id: The instance ID

    HTTP method and URL:

    GET https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id/backupRuns

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

  4. Restore the target instance from the backup.

    Before using any of the request data, make the following replacements:

    • project-id: The project ID
    • target-instance-id: The target instance ID
    • source-instance-id: The source instance ID
    • backup-id The backup ID

    HTTP method and URL:

    POST https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/target-instance-id/restoreBackup

    Request JSON body:

    {
      "restoreBackupContext":
      {
        "backupRunId": backup-id,
        "instanceId": "source-instance-id"
      }
    }
    

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

  5. After the restore operation completes, recreate any replicas that you deleted in this procedure.

Restore to the same instance

When you restore data from a backup to the same instance, you return the data on that instance to the state of when you took the backup. For information about restoring an instance, see General tips about performing a restore.

Console

  1. In the Google Cloud console, go to the Cloud SQL Instances page.

    Go to Cloud SQL Instances

  2. If the target instance has any read replicas, then use the more actions menu More actions icon. to delete them.
  3. To open the Overview page of an instance, click the instance name.
  4. From the SQL navigation menu, select Backups.
  5. Find the backup that you want to use, and then click Restore.
  6. In the Restore an instance from a backup page, confirm that you selected the correct backup in Review backup details.
  7. In Choose restore destination, select Overwrite the source instance.

    Check that the name of the source instance is specified in parentheses.

  8. To confirm your selection, enter the instance name in the Destination instance ID field.
  9. To start the restore process, click Restore.
  10. To check the status of the restore operation, go to the Operations page for the instance.
  11. After the restore operation completes, recreate any replicas that you deleted in this procedure.

gcloud

  1. To determine if the instance has any read replicas, use the gcloud sql instances describe command:
    gcloud sql instances describe INSTANCE_NAME

    Note any instances that are listed in the replicaNames column.

  2. To delete all replicas, use the gcloud sql instances delete command:
    gcloud sql instances delete REPLICA_NAME

    Repeat for each replica.

  3. To list the backups for the instance, use the gcloud sql backups list command:
    gcloud sql backups list --instance INSTANCE_NAME
  4. Find the backup that you want to use and record its ID value.
  5. To restore the instance from the specified backup, use the gcloud sql backups restore command:
    gcloud sql backups restore BACKUP_ID \
    --restore-instance=INSTANCE_NAME
  6. After the restore operation completes, recreate any replicas that you deleted in this procedure.

REST v1

  1. To get the ID of the backup that you want to use, list the backups for the instance.

    Before using any of the request data, make the following replacements:

    • project-id: The project ID
    • instance-id: The instance ID

    HTTP method and URL:

    GET https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id/backupRuns

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

  2. Restore the instance from the specified backup.

    Before using any of the request data, make the following replacements:

    • PROJECT_ID: the project ID
    • INSTANCE_ID: the instance ID
    • BACKUP_ID the backup ID

    HTTP method and URL:

    POST https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_ID/restoreBackup

    Request JSON body:

    {
      "restoreBackupContext":
      {
        "backupRunId": "BACKUP_ID",
      }
    }
    

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

  3. After the restore operation completes, recreate any replicas that you deleted in this procedure.

REST v1beta4

  1. To get the ID of the backup that you want to use, list the backups for the instance.

    Before using any of the request data, make the following replacements:

    • project-id: The project ID
    • instance-id: The instance ID

    HTTP method and URL:

    GET https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id/backupRuns

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

  2. Restore the instance from the specified backup.

    Before using any of the request data, make the following replacements:

    • PROJECT_ID: the project ID
    • INSTANCE_ID: the instance ID
    • BACKUP_RUN_ID: a date-and-time stamp of when Cloud SQL restores the instance from the backup

    HTTP method and URL:

    POST https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/INSTANCE_ID/restoreBackup

    Request JSON body:

    {
      "restoreBackupContext":
      {
        "backupRunId": "BACKUP_RUN_ID",
      }
    }
    

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

  3. After the restore operation completes, recreate any replicas that you deleted in this procedure.

Restore to an instance in another project

You can use the project parameter to restore data to an instance in a different project than the one where the backup was taken. When using the project parameter, call restoreBackup in the project and on the instance you want to restore data to. When you restore from a backup to a different instance, you update the data on the target instance to the state of the source instance when you took the backup.

Permissions

The user restoring to a different project must have the cloudsql.instances.restoreBackup permission for the target project and the cloudsql.backupRuns.get permission for the source instance. These permissions are included in the Cloud SQL Admin role.

To restore data to an instance in a different project:

gcloud

  1. List the backups for the instance.

    gcloud sql backups list --instance INSTANCE_NAME

    Replace INSTANCE_NAME with the name of the instance.

  2. Find the backup you want to use and record its ID value.
  3. Restore data to an instance in a different project.

    gcloud sql backups restore BACKUP_ID \
    --restore-instance=TARGET_INSTANCE_NAME \
    --backup-instance=SOURCE_INSTANCE_NAME \
    --backup-project=SOURCE_INSTANCE_PROJECT

    Make the following replacements:

    • BACKUP_ID: the ID of the backup. You obtained this ID earlier in this procedure.
    • TARGET_INSTANCE_NAME: the instance in the destination project to which you're restoring data.
    • SOURCE_INSTANCE_NAME: the instance in the source project that contains the data that you want to restore to the instance in the destination project.
    • SOURCE_INSTANCE_PROJECT: the project that contains the source instance.

REST v1

To obtain the backupId, run the following.

Before using any of the request data, make the following replacements:

  • project-id: The project ID
  • instance-id: The instance ID

HTTP method and URL:

GET https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id/backupRuns

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

Restore the backup to an instance in a different project:

Before using any of the request data, make the following replacements:

  • source-project-id: The source project ID
  • target-project-id: The target project ID
  • target-instance-id: The target instance ID
  • source-instance-id: The source instance ID
  • backup-id The backup ID

HTTP method and URL:

POST https://sqladmin.googleapis.com/v1/projects/target-project-id/instances/target-instance-id/restoreBackup

Request JSON body:

{
  "restoreBackupContext":
  {
    "backupRunId": backup-id,
    "project": "source-project-id",
    "instanceId": "source-instance-id"
  }
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

For more information about the project property, see restoreBackup

REST v1beta4

To obtain the backupId, run the following.

Before using any of the request data, make the following replacements:

  • project-id: The project ID
  • instance-id: The instance ID

HTTP method and URL:

GET https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id/backupRuns

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

Restore the backup to an instance in a different project:

Before using any of the request data, make the following replacements:

  • source-project-id: The source project ID
  • target-project-id: The target project ID
  • target-instance-id: The target instance ID
  • source-instance-id: The source instance ID
  • backup-id The backup ID

HTTP method and URL:

POST https://sqladmin.googleapis.com/sql/v1beta4/projects/target-project-id/instances/target-instance-id/restoreBackup

Request JSON body:

{
  "restoreBackupContext":
  {
    "backupRunId": backup-id,
    "project": "source-project-id",
    "instanceId": "source-instance-id"
  }
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

For more information about the project property, see restoreBackup

Restore from a final backup

You can use a final backup for the following scenarios:

  • Restore the final backup to a new instance
  • Restore to a new instance in a different project or region

Because you're using a final backup of a deleted instance to restore your instance, you can also use the backup to create an instance with the configuration of the deleted instance and recover your data.

Restore to a new instance

When you create an instance from a final backup, Cloud SQL uses the configuration settings of the instance from where the final backup is taken. After the instance is created, Cloud SQL restores the data to the state of when the final backup is taken.

Console

  1. In the Google Cloud console, go to the Cloud SQL Backups page.

    Go to Cloud SQL Backups

    This page lists all backups, including final backups, that are associated with a Google Cloud project.

  2. Click the final backup which contains data that you want to restore to a new instance.
  3. In the Final backup dialog, click Restore.
  4. In the Restore an instance from a backup page, confirm that you selected the correct backup in Review backup details.
  5. In Choose restore destination, select Restore to a new instance.
  6. From the Region menu, select the region for the new instance.
  7. In the Instance ID field, enter an ID for the new instance.
  8. To start the restore process, click Restore.
  9. To check the status of the restore operation, go to the Operations page for the instance.

gcloud

  1. To list the final backups for the source instance, use the gcloud sql backups list command:
    gcloud sql backups list \
    --filter='type:FINAL instance: SOURCE_INSTANCE_NAME'
  2. Find the backup that you want to use and record its NAME value.
  3. To restore a new instance from the specified final backup, use the gcloud sql backups restore command:
    gcloud sql backups restore BACKUP_NAME \
    --restore-instance=TARGET_INSTANCE_NAME 

REST v1

  1. To get the ID of the backup that you want to use, list the final backups for the source instance.

    Before using any of the request data, make the following replacements:

    • PROJECT_ID: the project ID
    • INSTANCE_ID: the instance ID

    HTTP method and URL:

    GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/backups?filter='type:FINAL AND instance:INSTANCE_ID'

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

  2. Restore a new instance from the specified final backup.

    Before using any of the request data, make the following replacements:

    • PROJECT_ID: the project ID
    • TARGET_INSTANCE_ID: the target instance ID
    • BACKUP_ID: the backup ID

    HTTP method and URL:

    POST https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/TARGET_INSTANCE_ID/restoreBackup

    Request JSON body:

    {
      backup: projects/PROJECT_ID/backups/BACKUP_ID
      restore_instance_settings: {}
    }
    

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

REST v1beta4

  1. To get the ID of the backup that you want to use, list the final backups for the source instance.

    Before using any of the request data, make the following replacements:

    • PROJECT_ID: the project ID
    • INSTANCE_ID: the instance ID

    HTTP method and URL:

    GET https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/backups?filter='type:FINAL AND instance:INSTANCE_ID'

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

  2. Restore a new instance from the specified final backup.

    Before using any of the request data, make the following replacements:

    • PROJECT_ID: the project ID
    • TARGET_INSTANCE_ID: the target instance ID
    • BACKUP_ID: the backup ID

    HTTP method and URL:

    POST https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/TARGET_INSTANCE_ID/restoreBackup

    Request JSON body:

    {
      backup: projects/PROJECT_ID/backups/BACKUP_ID
      restore_instance_settings: {}
    }
    

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

Restore to an existing instance

When you restore data from a final backup to an existing instance, you update the data on the target instance to the state of the source instance when you took the backup. For more information, see General tips about performing a restore and Tips and requirements for restoring to a different instance.

If you need a list of backups for the project and can't view them on the instance overview page because of an outage, you can use the backupRuns.list API.

Console

  1. In the Google Cloud console, go to the Cloud SQL Instances page.

    Go to Cloud SQL Instances

  2. If the target instance has any read replicas, then use the more actions menu More actions icon. to delete them.
  3. In the Google Cloud console, go to the Cloud SQL Backups page.

    Go to Cloud SQL Backups

    This page lists all backups, including final backups, that are associated with a Google Cloud project.

  4. Click the final backup which contains data that you want to restore to a different instance.
  5. In the Final backup dialog, click Restore.
  6. In the Restore an instance from a backup page, confirm that you selected the correct backup in Review backup details.
  7. In Choose restore destination, select Overwrite an existing instance.
  8. From the Instance to be overwritten menu, select the instance that you want to use for the restore. The instance that you select and all of its data are overwritten.

  9. To confirm your selection, in the Destination instance ID field, enter the name of the instance to be overwritten.
  10. To start the restore process, click Restore.
  11. To check the status of the restore operation, go to the Operations page for the instance.
  12. After the restore operation completes, recreate any replicas that you deleted in this procedure.

gcloud

  1. To determine if the target instance has any read replicas, use the gcloud sql instances describe command:
    gcloud sql instances describe TARGET_INSTANCE_NAME

    Note any instances that are listed in the replicaNames column.

  2. To delete all replicas, use the gcloud sql instances delete command:
    gcloud sql instances delete REPLICA_NAME

    Repeat for each replica.

  3. To list the final backups for the source instance, use the gcloud sql backups list command:
    gcloud sql backups list \
    --filter='type:FINAL instance: SOURCE_INSTANCE_NAME'
  4. Find the backup that you want to use and record its NAME value.
  5. To restore the target instance from the backup, use the gcloud sql backups restore command:
    gcloud sql backups restore BACKUP_NAME \
    --restore-instance=TARGET_INSTANCE_NAME
  6. After the restore operation completes, recreate any replicas that you deleted in this procedure.

REST v1

  1. To determine if the instance has any read replicas and to get the IDs of these replicas, list all replicas for the target instance.

    Before using any of the request data, make the following replacements:

    • PROJECT_ID: the project ID
    • INSTANCE_ID: the instance ID

    HTTP method and URL:

    GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_ID?fields=replicaNames

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

  2. Delete all replicas.

    Before using any of the request data, make the following replacements:

    • PROJECT_ID: the project ID
    • REPLICA_ID: the replica ID

    HTTP method and URL:

    DELETE https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/REPLICA_ID

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

    Repeat for each replica.

  3. To get the ID of the final backup that you want to use, list the backups for the source instance.

    Before using any of the request data, make the following replacements:

    • PROJECT_ID: the project ID
    • INSTANCE_ID: the instance ID

    HTTP method and URL:

    GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/backups?filter='type:FINAL AND instance:INSTANCE_ID'

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

    Find the backup for the instance that you need to restore.
  4. Restore the target instance from the backup.

    Before using any of the request data, make the following replacements:

    • PROJECT_ID: the project ID
    • TARGET_INSTANCE_ID: the target instance ID
    • BACKUP_ID: the backup ID

    HTTP method and URL:

    POST https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/TARGET_INSTANCE_ID/restoreBackup

    Request JSON body:

    {
      backup: projects/PROJECT_ID/backups/BACKUP_ID
    }
    

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

  5. After the restore operation completes, recreate any replicas that you deleted in this procedure.

REST v1beta4

  1. To determine if the instance has any read replicas and to get the IDs of these replicas, list all replicas for the target instance.

    Before using any of the request data, make the following replacements:

    • PROJECT_ID: the project ID
    • INSTANCE_ID: the instance ID

    HTTP method and URL:

    GET https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/INSTANCE_ID?fields=replicaNames

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

  2. Delete all replicas.

    Before using any of the request data, make the following replacements:

    • PROJECT_ID: the project ID
    • REPLICA_ID: the replica ID

    HTTP method and URL:

    DELETE https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/REPLICA_ID

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

    Repeat for each replica.

  3. To get the ID of the final backup that you want to use, list the backups for the source instance.

    Before using any of the request data, make the following replacements:

    • PROJECT_ID: the project ID
    • INSTANCE_ID: the instance ID

    HTTP method and URL:

    GET https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/backups?filter='type:FINAL AND instance:INSTANCE_ID'

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

    Find the backup for the instance that you need to restore.
  4. Restore the target instance from the backup.

    Before using any of the request data, make the following replacements:

    • PROJECT_ID: the project ID
    • TARGET_INSTANCE_ID: the target instance ID
    • BACKUP_ID: the backup ID

    HTTP method and URL:

    POST https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/TARGET_INSTANCE_ID/restoreBackup

    Request JSON body:

    {
      backup: projects/PROJECT_ID/backups/BACKUP_ID
    }
    

    To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

  5. After the restore operation completes, recreate any replicas that you deleted in this procedure.

Restore to an instance in another project

The user restoring data to an instance in a different project must have the cloudsql.instances.restoreBackup permission for the target project and the cloudsql.backupRuns.get permission for the source instance. These permissions are included in the Cloud SQL Admin role.

To restore data to an instance in a different project:

REST v1

To obtain the backupId for the final backup, run the following:

Before using any of the request data, make the following replacements:

  • PROJECT_ID: the project ID
  • INSTANCE_ID: the instance ID

HTTP method and URL:

GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/backups?filter='type:FINAL AND instance:INSTANCE_ID'

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

Restore the backup to an instance in a different project:

Before using any of the request data, make the following replacements:

  • PROJECT_ID: the project ID
  • TARGET_INSTANCE_ID: the target instance ID
  • BACKUP_ID: the backup ID

HTTP method and URL:

POST https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/TARGET_INSTANCE_ID/restoreBackup

Request JSON body:

{
  backup: projects/PROJECT_ID/backups/BACKUP_ID
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

For more information about the project property, see restoreBackup

REST v1beta4

To obtain the backupId for the final backup, run the following:

Before using any of the request data, make the following replacements:

  • PROJECT_ID: the project ID
  • INSTANCE_ID: the instance ID

HTTP method and URL:

GET https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/backups?filter='type:FINAL AND instance:INSTANCE_ID'

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

Restore the backup to an instance in a different project:

Before using any of the request data, make the following replacements:

  • PROJECT_ID: the project ID
  • TARGET_INSTANCE_ID: the target instance ID
  • BACKUP_ID: the backup ID

HTTP method and URL:

POST https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/TARGET_INSTANCE_ID/restoreBackup

Request JSON body:

{
  backup: projects/PROJECT_ID/backups/BACKUP_ID
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

For more information about the project property, see restoreBackup

Restore to a new instance in another region

The user restoring data to a new instance in a different region must have the cloudsql.instances.restoreBackup permission for the target project and the cloudsql.backupRuns.get permission for the source instance. These permissions are included in the Cloud SQL Admin role.

Also, to create an instance in a different region, you must meet the criteria of the organization policies for that region.

To restore data to a new instance in a different region:

gcloud

  1. To list the final backups for the source instance, use the gcloud sql backups list command:
    gcloud sql backups list \
    --filter='type:FINAL instance: SOURCE_INSTANCE_NAME'
  2. Find the backup that you want to use and record its NAME value.
  3. To use the final backup to restore data to a new instance in a different region, use the gcloud sql backups restore command:
    gcloud sql backups restore BACKUP_NAME \
    --restore-instance=TARGET_INSTANCE_NAME \
    --region=TARGET_REGION 

REST v1

To obtain the backupId for the final backup, run the following:

Before using any of the request data, make the following replacements:

  • PROJECT_ID: the project ID
  • INSTANCE_ID: the instance ID

HTTP method and URL:

GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/backups?filter='type:FINAL AND instance:INSTANCE_ID'

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

Restore the backup to a new instance in a different region:

Before using any of the request data, make the following replacements:

  • PROJECT_ID: the project ID
  • TARGET_INSTANCE_ID: the target instance ID
  • BACKUP_ID: the backup ID
  • REGION: the region for the target instance (for example, us-central1)

HTTP method and URL:

POST https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/TARGET_INSTANCE_ID/restoreBackup

Request JSON body:

{
  backup: projects/PROJECT_ID/backups/BACKUP_ID
  restore_instance_settings: {
    region: REGION
  }
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

For more information about the project property, see restoreBackup

REST v1beta4

To obtain the backupId for the final backup, run the following:

Before using any of the request data, make the following replacements:

  • PROJECT_ID: the project ID
  • INSTANCE_ID: the instance ID

HTTP method and URL:

GET https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/backups?filter='type:FINAL AND instance:INSTANCE_ID'

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

Restore the backup to a new instance in a different region:

Before using any of the request data, make the following replacements:

  • PROJECT_ID: the project ID
  • TARGET_INSTANCE_ID: the target instance ID
  • BACKUP_ID: the backup ID
  • REGION: the region for the target instance (for example, us-central1)

HTTP method and URL:

POST https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/TARGET_INSTANCE_ID/restoreBackup

Request JSON body:

{
  backup: projects/PROJECT_ID/backups/BACKUP_ID
  restore_instance_settings: {
    region: REGION
  }
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

For more information about the project property, see restoreBackup

Perform a point-in-time recovery

To perform a point-in-time recovery, see Point-in-time recovery.

What's next