Manage final backups

This page describes how to manage final backups for your Cloud SQL instance. Before you delete an instance, you can take a final backup of the instance. You can then restore the final backup to a new or existing instance. This way, you can recreate any instances that you delete accidentally or use these instances for any disaster recovery scenarios.

Unlike automated and on-demand backups, which are associated with an instance, you can take a final backup before you delete the instance. Cloud SQL stores this backup beyond the lifetime of the instance.

You can use existing gcloud CLI commands to list, describe, update, and delete a final backup. If you're using custom roles, then add the following permissions to the roles:

  • cloudsql.backupRuns.list
  • cloudsql.backupRuns.get
  • cloudsql.backupRuns.update
  • cloudsql.backupRuns.delete

For more information about these permissions, see Required permissions. Also, for more information about how backups work, see About Cloud SQL backups.

Required permissions

Google Cloud console

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

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

gcloud CLI

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

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

REST

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

Action Method Required permissions
List final backups backups.list cloudsql.backupRuns.list
Describe a final backup backups.describe cloudsql.backupRuns.get
Update a final backup backups.patch cloudsql.backupRuns.update
Delete a final backup backups.delete cloudsql.backupRuns.delete

View a list of final backups

You can view a list of final backups and details about a backup by using the Google Cloud console, gcloud CLI, or the Cloud SQL API.

The Google Cloud console doesn't show skipped or failed backups in the backup history. To see these types of backups, use gcloud or the Cloud SQL API.

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. To view details about a final backup, click the backup. A Final backup dialog appears. This dialog displays the following information:

    • The date and time of when the instance, which was used to create the final backup, was deleted
    • The name and version of the deleted instance
    • A date-and-time stamp of how long Cloud SQL retains the final backup
    • A description of the final backup

gcloud

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

    gcloud sql backups list \
    --filter="type=FINAL"
  2. To view details about a final backup, use the gcloud sql backups describe command:

    gcloud sql backups describe \
    BACKUP_NAME

    You obtain the BACKUP_NAME from the output of running the gcloud sql backups list command. The BACKUP_NAME has the following format: projects/PROJECT_ID/backups/BACKUP_ID.

REST v1

Get a list of final backups

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

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

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

View details about a final backup

Use this example to view the details about a final backup. For a complete list of parameters for this call, see the backupRuns.get 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 final backups

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

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

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

View details about a final backup

Use this example to view the details about a final backup. For a complete list of parameters for this call, see the backupRuns.get 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 a final backup

You can update how long Cloud SQL retains a final backup for an instance and the description for the backup by 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

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

  2. To update a final backup, click the backup. A Final backup dialog appears.
  3. To update how long Cloud SQL retains the final backup, complete the following actions:
    1. Click the Edit retention icon next to the Backup retained until field.
    2. Click the Select date icon next to the Retain backup until field.
    3. In the calendar, select the new date that indicates how long Cloud SQL retains the final backup.
    4. Click Update. You're returned to the Cloud SQL Backups page.
  4. To update the description of the final backup, complete the following actions:
    1. Click the final backup.
    2. Click the Edit description icon next to the Description field.
    3. In the Describe this backup field, enter the updated description for the final backup.
    4. Click Update. You're returned to the Cloud SQL Backups page.

gcloud

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

    gcloud sql backups list \
    --filter="type=FINAL"
  2. To update the description and retention period of a final backup, use the gcloud sql backups patch command:

    gcloud sql backups patch \
    BACKUP_NAME  \
    --description=DESCRIPTION /
    --expiry-time=DATE-AND-TIME-STAMP | --ttl-days=NUMBER-OF-DAYS

    You obtain the BACKUP_NAME from the output of running the gcloud sql backups list command. The BACKUP_NAME has the following format: projects/PROJECT_ID/backups/BACKUP_ID.

    For the --expiry-time and --ttl-days flags, use the following guidelines:

    • For the --expiry-time flag, specify a date-and-time stamp of when Cloud SQL deletes the final backup automatically.
    • For the --ttl-days flag, specify the retention period of the final backup (from 1 to 365 days). This is known as time to live (TTL). The retention period starts from the current date and time, and the maximum retention period that Cloud SQL allows is 1 year (or 365 days).

REST v1

Get a list of final backups

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

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

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

Update the retention period

You can update the retention period of a final backup in one of the following ways:

  • Retention days: Modify the number of days that Cloud SQL retains the backup.
  • Expiration time: Provide an updated date-and-time stamp for when Cloud SQL deletes the backup automatically.
Update the retention days

Use this example to update the number of days that Cloud SQL retains the final backup. For a complete list of parameters for this call, see the backupRuns.update 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.
  • TTL_DAYS: the retention period of the final backup (from 1 to 365 days). This is known as time to live (TTL). The retention period starts from the current date and time, and the maximum retention period that Cloud SQL allows is 1 year (or 365 days).

HTTP method and URL:

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

Request JSON body:

{
        "backup": {
            expiration: {
            "ttl_days": TTL_DAYS,
            }
         },
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

Update the expiration time

Use this example to provide an updated date-and-time stamp for when Cloud SQL deletes the backup. For a complete list of parameters for this call, see the backupRuns.update 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.
  • DATE_AND_TIME_STAMP: a date-and-time stamp of when Cloud SQL deletes the final backup automatically.

HTTP method and URL:

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

Request JSON body:

{
        "backup": {
            expiration: {
            "expiry_time": DATE_AND_TIME_STAMP,
            }
         },
}

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 final backup. For a complete list of parameters for this call, see the backupRuns.update 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 final backups

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

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

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

Update the retention period

You can update the retention period of a final backup in one of the following ways:

  • Retention days: Modify the number of days that Cloud SQL retains the backup
  • Expiration time: Provide an updated date-and-time stamp for when Cloud SQL deletes the backup automatically.
Update the retention days

Use this example to update the number of days that Cloud SQL retains the final backup. For a complete list of parameters for this call, see the backupRuns.update 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.
  • TTL_DAYS: the retention period of the final backup (from 1 to 365 days). This is known as time to live (TTL). The retention period starts from the current date and time, and the maximum retention period that Cloud SQL allows is 1 year (or 365 days).

HTTP method and URL:

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

Request JSON body:

{
        "backup": {
            expiration: {
            "ttl_days": TTL_DAYS,
            }
         },
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

Update the expiration time

Use this example to provide an updated date-and-time stamp for when Cloud SQL deletes the backup. For a complete list of parameters for this call, see the backupRuns.update 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.
  • DATE_AND_TIME_STAMP: a date-and-time stamp of when Cloud SQL deletes the final backup automatically.

HTTP method and URL:

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

Request JSON body:

{
        "backup": {
            expiration: {
            "expiry_time": DATE_AND_TIME_STAMP,
            }
         },
}

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 final backup. For a complete list of parameters for this call, see the backupRuns.update 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 final backup

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

Deleting a backup might not free up as much space as the size of the backup. This is because backups are incremental, so deleting an older backup might transfer some of its contents to a more recent backup to preserve the integrity of the newer backup.

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. For the final backup that you want to delete, click more actions More actions icon., and then select Delete.
  3. In the Delete final backup? window, enter the name of the instance that you used to create the final backup, and then click Delete.

gcloud

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

    gcloud sql backups list \
    --filter="type=FINAL"
  2. To delete a final backup, use the gcloud sql backups delete command:

    gcloud sql backups delete \
    BACKUP_NAME

    You obtain the BACKUP_NAME from the output of running the gcloud sql backups list command. The BACKUP_NAME has the following format: projects/PROJECT_ID/backups/BACKUP_ID.

REST v1

Get a list of final backups

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

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

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

Delete a final backup

Use this example to delete a final backup. For a complete list of parameters for this call, see the backupRuns.delete 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 final backups

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

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

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

Delete a final backup

Use this example to delete a final backup. For a complete list of parameters for this call, see the backupRuns.delete 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