Restoring an Instance

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

For more information about restore operations or point-in-time recovery, see Overview of restoring an instance.

Restoring an instance from a backup

You can restore a backup to the instance from which the backup was taken, or you can restore a backup to another instance in the same project.

Restoring from a backup to the same instance

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

Console

  1. Go to the Cloud SQL Instances page in the Google Cloud Platform Console.

    Go to the Cloud SQL Instances page

  2. Select the instance you want to restore.
  3. In the Recent backups list, find the backup from which to restore and select Restore from the more actions menu More actions icon..
  4. In the Restore instance from backup dialog box, click OK to start the restore process.

    The default target instance is the same instance from which you started the restore process.

    The restore backup dialog box.

  5. You can check the status of the restore by going to the Operations page of the instance.

gcloud

  1. List the backups for the instance:
    gcloud sql backups list --instance [INSTANCE_NAME]
  2. Find the backup you want to use and record its DUE_TIME value.
    Be sure to select a backup that is marked as `SUCCESSFUL`.
  3. Restore from the specified backup:
    gcloud sql instances restore-backup [INSTANCE_NAME] --due-time [DUE_TIME]

Restoring from a backup to a different instance

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. For more information, see General tips about performing a restore and Tips and requirements for restoring to a different instance.

Console

  1. Go to the Cloud SQL Instances page in the Google Cloud Platform Console.

    Go to the Cloud SQL Instances page

  2. Select the instance from which you want to restore.
  3. In the Backups list, find the backup from which to restore and select Restore.
  4. In the Restore instance from backup dialog, select a Target instance to which to restore the backup, and then click OK.
  5. You can check the status of the restore by going to the Operations page of the target instance.

cURL

  1. List the backups for the source instance to get the id of the backup you want to use.
    ACCESS_TOKEN="$(gcloud auth print-access-token)"
    curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
         -X GET \
         https://www.googleapis.com/sql/v1beta4/projects/[PROJECT-ID]/instances/[SOURCE_INSTANCE_NAME]/backupRuns
    
  2. Restore the target instance from the backup:
    curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
         --header 'Content-Type: application/json' \
         --data '{ "restoreBackupContext": {"backupRunId": "[BACKUP_ID]", "instanceId": "[SOURCE_INSTANCE_NAME]", "kind": "sql#restoreBackupContext"}}' \
         -X POST \
         https://www.googleapis.com/sql/v1beta4/projects/[PROJECT-ID]/instances/[TARGET_INSTANCE_NAME]/restoreBackup
    

What's next

Send feedback about...

Cloud SQL for PostgreSQL