Manage retained backups

This page describes how to enable, disable, and manage retained backups for your Cloud SQL instances.

Retained backups are backups that are retained after an instance is deleted. These backups include on-demand and automated backups that are created when an instance was live. For more information on how retained backups work, see Retained backups.

You can enable retained backups at any time for an instance by editing the instance. You can also restore a retained backup to a new or existing instance.

Before you begin

To manage retained backups in a Google Cloud project, you need the following permissions:

Task Required permissions
List backups cloudsql.backupRuns.list
Describe a backup cloudsql.backupRuns.get
Update a backup cloudsql.backupRuns.update
Delete a backup cloudsql.backupRuns.delete

gcloud CLI

To manage retained backups in a Google Cloud project, you need the following permissions:

Action Command Required permissions
List backups gcloud sql backups list cloudsql.backupRuns.list
Describe a backup gcloud sql backups describe cloudsql.backupRuns.get
Update a backup gcloud sql backups patch cloudsql.backupRuns.update
Delete a backup gcloud sql backups delete cloudsql.backupRuns.delete

REST

To manage retained backups in a Google Cloud project, you need the following permissions:

Action Method Required permissions
List backups backups.listBackup cloudsql.backupRuns.list
Describe a backup backups.getBackup cloudsql.backupRuns.get
Update a backup backups.updateBackup cloudsql.backupRuns.update
Delete a backup backups.deleteBackup cloudsql.backupRuns.delete

Enable retained backups for an instance

You can enable retained backups in the Data Protection configuration options for an instance when you create an instance or when you edit an existing instance.

View a list of all retained backups

You can see a list of all retained backups for your Google Cloud project using Google Cloud console, gcloud CLI, or the Cloud SQL API. Backups will include details such as the name of the backup, the instance it belongs to, the type of backup, and the time the instance was deleted. Since the name of a deleted instance can be reused, we recommend using the instance deletion time field to differentiate which instance a particular backup belongs to. For a live instance, this field is blank.

Console

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

    Go to Cloud SQL Backups

  2. Click the name of the deleted instance you want to view backups for.

    You will see a list of all retained and final backups, and their details for the deleted instance.

gcloud

  1. To get a list of all backups that are associated with a Google Cloud project, use the gcloud sql backups list command:

    gcloud sql backups list
    --project=PROJECT_ID
    

    Replace the following:

    • PROJECT_ID: the ID of your Google Cloud project.
  2. To view details about a specific retained backup, use the gcloud sql backups describe command:

    gcloud sql backups describe BACKUP_NAME
    --project=PROJECT_ID
    

    Replace the following:

    • BACKUP_NAME: the name of your retained backup.
    • PROJECT_ID: the ID of your Google Cloud project.

REST v1

Get a list of all retained backs

Use this example to get a list of all retained backups associated with a Google Cloud project. For a complete list of parameters for this call, see the backups.listBackups page.

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

  • PROJECT_ID: the project ID

HTTP method and URL:

GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/backups

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

View details for a retained backup

Use this example to view the details of a retained backup. For a complete list of parameters for this call, see the backup.getBackup page.

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

  • PROJECT_ID: the project ID.
  • BACKUP_ID: the backup ID. You obtain this ID from the output of running the previous call.

HTTP method and URL:

GET https://sqladmin.googleapis.com/v1/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:

REST v1beta4

Get a list of all retained backs

Use this example to get a list of all retained backups associated with a Google Cloud project. For a complete list of parameters for this call, see the backups.listBackups page.

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

  • PROJECT_ID: the project ID

HTTP method and URL:

GET https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/backups

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

View details for a retained backup

Use this example to view the details of a retained backup. For a complete list of parameters for this call, see the backups.getBackup page.

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

  • PROJECT_ID: the project ID.
  • BACKUP_ID: the backup ID. You obtain this ID from the output of running the previous call.

HTTP method and URL:

GET https://sqladmin.googleapis.com/sql/v1beta4/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:

Update the description of a retained backup

You can update the description of a retained backup at any time to make it easier to identify your backups.

Console

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

    Go to Cloud SQL Backups

  2. Click the name of the deleted instance you want to view backups for.

    You will see a list of all retained and final backups, and their details for the deleted instance.

  3. For the retained backup you want to update, click more actions More actions icon., and then select Edit description.

  4. In the Edit Backup Description window, update the description for your backup.

  5. Click Update.

gcloud

To update the description of your retained backup, use the gcloud sql backups patch command:

gcloud sql backups patch BACKUP_NAME
--description=BACKUP_DESCRIPTION

Replace the following:

  • BACKUP_NAME: the name of your retained backup.
  • BACKUP_DESCRIPTION: the new description you want to add to your retained backup.

REST v1

Get a list of all retained backs

Use this example to get a list of all retained backups associated with a Google Cloud project. For a complete list of parameters for this call, see the backups.listBackups page.

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

  • PROJECT_ID: the project ID

HTTP method and URL:

GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/backups

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

Update the description

Use this example to update the description of the retained backup. For a complete list of parameters for this call, see the backups.updateBackup page.

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

  • PROJECT_ID: the project ID.
  • BACKUP_ID: the backup ID. You obtain this ID from the output of running the previous call.
  • DESCRIPTION: the updated description for the final backup.

HTTP method and URL:

PATCH https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/backups/BACKUP_ID?update_mask=description

Request JSON body:

{
        "backup": {
            "description": DESCRIPTION,
         },
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

REST v1beta4

Get a list of all retained backs

Use this example to get a list of all retained backups associated with a Google Cloud project. For a complete list of parameters for this call, see the backups.listBackups page.

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

  • PROJECT_ID: the project ID

HTTP method and URL:

GET https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/backups

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

Update the description

Use this example to update the description of the retained backup. For a complete list of parameters for this call, see the backups.updateBackup page.

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

  • PROJECT_ID: the project ID.
  • BACKUP_ID: the backup ID. You obtain this ID from the output of running the previous call.
  • DESCRIPTION: the updated description for the final backup.

HTTP method and URL:

PATCH https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/backups/BACKUP_ID?update_mask=description

Request JSON body:

{
        "backup": {
            "description": DESCRIPTION,
         },
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

Delete a retained backup

You can delete a retained backup using the Google Cloud console, gcloud CLI, or the Cloud SQL API.

Console

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

    Go to Cloud SQL Backups

  2. Click the name of the deleted instance you want to view backups for.

    You will see a list of all retained and final backups, and their details for the deleted instance.

  3. For the retained backup you want to delete, click more actions More actions icon., and then select Delete.

  4. In the Delete backup window, enter the name of deleted instance, and then click Delete.

gcloud

To delete a retained backup, use the gcloud sql backups delete command:

gcloud sql backups delete BACKUP_NAME

Replace the following:

  • BACKUP_NAME: the name of your retained backup.

REST v1

Get a list of all retained backs

Use this example to get a list of all retained backups associated with a Google Cloud project. For a complete list of parameters for this call, see the backups.listBackups page.

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

  • PROJECT_ID: the project ID

HTTP method and URL:

GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/backups

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

Delete a retained backup

Use this example to delete a retained backup. For a complete list of parameters for this call, see the backups.deleteBackup page.

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

  • PROJECT_ID: the project ID.
  • BACKUP_ID: the backup ID. You obtain this ID from the output of running the previous call.

HTTP method and URL:

DELETE https://sqladmin.googleapis.com/v1/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:

REST v1beta4

Get a list of all retained backs

Use this example to get a list of all retained backups associated with a Google Cloud project. For a complete list of parameters for this call, see the backups.listBackups page.

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

  • PROJECT_ID: the project ID

HTTP method and URL:

GET https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/backups

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

Delete a retained backup

Use this example to delete a retained backup. For a complete list of parameters for this call, see the backups.deleteBackup page.

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

  • PROJECT_ID: the project ID.
  • BACKUP_ID: the backup ID. You obtain this ID from the output of running the previous call.

HTTP method and URL:

DELETE https://sqladmin.googleapis.com/sql/v1beta4/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:

What's next