Restore a Cloud SQL instance from a backup vault

For more information about granting roles, see Manage access to projects, folders, and organizations .

Restore a Cloud SQL instance from the most recent backup

Use the following instructions to restore a Cloud SQL instance.

Console

  1. In the Google Cloud console, go to the Vaulted backupspage.
  • End user should have roles/cloudsql.admin in the project where the target instance lives.
  • End user should have roles/backupdr.restoreUser in the project where the source backups exists. Go to Vaulted backups The Vaulted backupspage lists only the data resources that have backup plans applied and their backups stored in a backup vault within that project.
  1. Select the backup that you want to restore. Either from the backup details page for the backup, or from the menu, select Restore.

The Restore pagedisplays where you select the following restore options:

  • The Resource typeis prefilled with Cloud SQL .
  • In Resource name, select the Cloud SQL instance to restore.
  • When you click Backup, a pane opens showing all available backups. Select the specific backup to restore.
  • For Choose the restore destination, select the project into which you want to restore the Cloud SQL instance.
  • Click Continue.
  • The next page shows the restore details so far, and prompts you to Choose restore destination, with these options:

    • Restore to a new instance: This creates a new instance based on the configuration stored in your backup. You can customize the instance after the restore is complete. Provide a new Instance IDusing lowercase letters, numbers, and hyphens. Start with a letter.
    • Overwrite an existing instance: Select an existing instance to overwrite from the list of available instances.
    • Overwrite the source instance: This will overwrite your current instance. All the current data on the selected instance will be overwritten, including previous point-in-time recovery logs. The overwritten data cannot be recovered later. This is not recommended for production use.

gcloud

Before you begin

  1. You need to first find the data source that contains the backup that you want to restore. You can find the data source from a Cloud SQL instance project or a backup vault project:

    • From Cloud SQL instance project: Use data-source-reference
     gcloud  
    alpha  
    backup-dr  
    data-source-references  
    fetch-for-resource-type  
    sqladmin.googleapis.com/Instance  
     \ 
    --location = 
     LOCATION 
      
     \ 
    --project = 
     CSQL_INSTANCE_PROJECT_ID 
      
     \ 
    --filter = 
     'dataSourceGcpResourceInfo.cloudSqlInstanceProperties.name="projects/ CSQL_INSTANCE_PROJECT_ID 
    /instances/ CSQL_INSTANCE_ID 
    "' 
      
     \ 
    --format = 
     "table(RESOURCE_NAME,DATA_SOURCE)" 
     
    

    Replace the following:

      + 
      
      LOCATION 
     
     : 
      
     the 
      
     location 
      
     of 
      
     the 
      
     backup 
      
     vault 
     . 
     + 
      
      CSQL_INSTANCE_ID 
     
     : 
      
     the 
      
     database 
      
     name 
      
     of 
      
     the 
      
     Cloud 
      
     SQL 
      
     instance 
     . 
     + 
      
      CSQL_INSTANCE_PROJECT_ID 
     
     : 
      
     the 
      
     project 
      
     containing 
      
     the 
      
     Cloud 
      
     SQL 
      
     instance 
     . 
     
    
    • From a backup vault project: Use data-source
     gcloud  
    backup-dr  
    data-sources  
    list  
     \ 
    --location = 
     LOCATION 
      
     \ 
    --project = 
     BACKUP_VAULT_PROJECT_ID 
      
     \ 
    --filter = 
     'dataSourceGcpResource.cloudSqlInstanceDatasourceProperties.name=projects/ CSQL_INSTANCE_PROJECT_ID 
    /instances/ CSQL_INSTANCE_ID 
    ' 
      
     \ 
    --format = 
     "table(dataSourceGcpResource.cloudSqlInstanceDatasourceProperties.name:label=RESOURCE_NAME,name:label=DATA_SOURCE)" 
     
    

    Replace the following:

      + 
      
      LOCATION 
     
     : 
      
     the 
      
     location 
      
     of 
      
     the 
      
     backup 
      
     vault 
     . 
     + 
      
      CSQL_INSTANCE_ID 
     
     : 
      
     the 
      
     name 
      
     of 
      
     the 
      
     Cloud 
      
     SQL 
      
     instance 
     . 
     + 
      
      CSQL_INSTANCE_PROJECT_ID 
     
     : 
      
     the 
      
     project 
      
     containing 
      
     the 
      
     Cloud 
      
     SQL 
      
     instance 
     . 
     + 
      
      BACKUP_VAULT_PROJECT_ID 
     
     : 
      
     the 
      
     project 
      
     containing 
      
     the 
      
     backup 
      
     vault 
     . 
     
    
  2. List and select the backup to restore. You need to list all the backups in the data source. To do this, use the backups list command.

     gcloud  
    backup-dr  
    backups  
    list  
    --data-source = 
     DATA_SOURCE 
      
     \ 
    --format = 
     "table(consistencyTime,backupType,name:label=BACKUP_NAME)" 
     
    

Restoring the backup

To restore a Cloud SQL instance using the Cloud SQL restore command, use the following commands.

   
gcloud  
sql  
backups  
restore  
 BACKUP_NAME 
  
 \ 
  
--restore-instance = 
 RESTORE_INSTANCE 
  
 \ 
  
--project = 
 RESTORE_PROJECT 
 

Replace the following:

   
 + 
  
  BACKUP_NAME 
 
 : 
  
 the 
  
 backup 
  
 vault 
  
 name 
  
 you 
  
 want 
  
 to 
  
 restore 
  
 data 
  
 from 
 . 
  
 + 
  
  RESTORE_INSTANCE 
 
 : 
  
 The 
  
 target 
  
 Cloud 
  
 SQL 
  
 instance 
  
 name 
 . 
  
 + 
  
  RESTORE_PROJECT 
 
 : 
  
 the 
  
 project 
  
 where 
  
 you 
  
 want 
  
 to 
  
 restore 
  
 the 
  
 Cloud 
  
 SQL 
  
 instance 
 . 
 

To override other properties, see Overview of Backup and DR Service Google Cloud CLI commands .

Restore a Cloud SQL instance to a different point-in-time

Use the following instructions to restore a Cloud SQL instance to a point in time. When you restore to a point in time, you create a Cloud SQL clone.

  1. In the Google Cloud console, go to the Vaulted backupspage.

    Go to Vaulted backups

  2. At the top of the table, select Filter table > Resource type. Select Cloud SQL. This limits the display to only the Cloud SQL instances that have backup plans applied and their backups stored in a backup vault within a project.

  3. Click Restore from a point in time. The Cloud SQL Create a clonepage opens.

  4. Follow the procedures in Perform PITR by using the backup vault .

Design a Mobile Site
View Site in Mobile | Classic
Share by: