To reduce backup storage costs and remove backups that you no longer need, you
can delete an AlloyDB for PostgreSQL backup.


## Before you begin

- The Google Cloud project you are using must have been [enabled to access AlloyDB](https://docs.cloud.google.com/alloydb/docs/quickstart/create-and-connect.md.txt#before-you-begin).
- You must have one of these IAM roles in the Google Cloud project you are using:
  - `roles/alloydb.admin` (the AlloyDB Admin predefined IAM role)
  - `roles/owner` (the Owner basic IAM role)
  - `roles/editor` (the Editor basic IAM role)

  If you don't have any of these roles, contact your Organization Administrator to request
  access.

<br />

## Procedure

### gcloud

To use the gcloud CLI, you can
[install and initialize](https://docs.cloud.google.com/sdk/docs/install-sdk.md.txt) the Google Cloud CLI, or you
can use [Cloud Shell](https://docs.cloud.google.com/shell/docs/using-cloud-shell.md.txt).

Use the `backups delete` command to delete
an AlloyDB backup.

```
gcloud alloydb backups delete BACKUP_ID \
    --region=REGION_ID \
    --project=PROJECT_ID
```

Replace the following:

- <var translate="no">BACKUP_ID</var>: The ID of the backup. You can find a backup's ID by [viewing a list of backups](https://docs.cloud.google.com/alloydb/docs/backup/list.md.txt).
- <var translate="no">REGION_ID</var>: The ID of the region where the backup is placed.
- <var translate="no">PROJECT_ID</var>: The ID of the project where the backup is placed.

## Restrictions on deleting backups

You can delete on-demand backups at any time, unless they are [enhanced
backups](https://docs.cloud.google.com/alloydb/docs/backup/overview#enhanced-backups) within an enforced
retention period. You can delete automated backups unless a subsequent
automated backup depends on them.
AlloyDB limits the circumstances under which you can
delete continuous backups. AlloyDB requires the presence
of these backups for [continuous backup and
recovery](https://docs.cloud.google.com/alloydb/docs/backup/overview#continuous-backup) to work.

AlloyDB lets you delete a continuous backup only if
at least one of these circumstances is true:

- You have [disabled continuous backup and
  recovery](https://docs.cloud.google.com/alloydb/docs/backup/configure#disable-continuous) on this
  cluster.

- The backup that you want to delete is older than the cluster's
  configured recovery window for continuous backup and recovery.

In addition, AlloyDB doesn't let you delete a continuous
backup if a subsequent continuous backup depends on it. Like automated
backups, continuous backups are incremental backups, and they rely on the
existence of specific previous backups to keep your data safe and restorable.