To stop an unneeded or unintended backup before it finishes, you can cancel an
in-progress an AlloyDB for PostgreSQL backup operation.

You can cancel a running backup operation if:

- The source cluster of the backup is in the "Ready" state.
- The backup is in the `CREATING` state.

To cancel the backup operation, you cancel the long-running operation that
AlloyDB initiated to perform the operation. Note that in some
cases, your attempt to cancel the long-running operation can fail due to the
current status of the operation.


## 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 `operations cancel` command to cancel the long-running
operation performing an AlloyDB backup.

```
gcloud alloydb operations cancel OPERATION_ID \
    --region=REGION_ID \
    --project=PROJECT_ID
```

- <var translate="no">OPERATION_ID</var>: The ID of the long-running operation, as reported by AlloyDB when the backup was started.
- <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.