Schedule automatic backups

Stay organized with collections Save and categorize content based on your preferences.

This page describes how to schedule automatic backups of an AlloyDB cluster's data.

To schedule automatic backups, you specify:

  • The day or days of the week when you want backups to be taken
  • The time or times (in the UTC timezone) to start the backup operations

The schedule you define can also include these features:

  • A retention policy to delete old backups automatically, expressed either as an amount of time to keep backups or as a number of backups to keep.

    If you don't specify a retention policy, all automated backups are retained.

  • A timeout that AlloyDB waits before automatically cancelling an uncompleted attempt to take a new automatic backup.

    If you don't specify a timeout, AlloyDB uses a default of 1 hour.

Prerequisites

  • The Cloud project you are using must have been enabled to access AlloyDB.
  • You must have one of these IAM roles in the 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.

Set an automatic backup schedule

gcloud

To use the gcloud CLI, you can install and initialize the Google Cloud CLI, or you can use Cloud Shell.

Use the gcloud beta alloydb clusters update command to define a schedule for creating automatic backups:

gcloud beta alloydb clusters update CLUSTER_ID \
    --automated-backup-days-of-week=DAYS_LIST \
    --automated-backup-start-times=UTC_TIMES_LIST \
    --region=REGION_ID \
    --project=PROJECT_ID

Replace the following:

  • CLUSTER_ID: The ID of the cluster you want to define the schedule for.
  • DAYS_LIST: A comma-separated list of one or more days when you want automatic backups to be taken. Valid values are MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, and SUNDAY.
  • UTC_TIMES_LIST: A comma-separated list of one or more times when you want automatic-backup operations to start on the specified days. Specify times in the format HH:MM on a 24-hour cycle in UTC time.
  • REGION_ID: The ID of the region where the cluster is placed.
  • PROJECT_ID: The ID of the project where the cluster is placed.

For example:

gcloud beta alloydb clusters update my-cluster \
    --automated-backup-days-of-week="MONDAY,THURSDAY" \
    --automated-backup-start-times="00:00" \
    --region=us-central-1 \
    --project=my-project

If you wish to encrypt scheduled backups using a customer-managed encryption key (CMEK) instead of the default Google-managed encryption, then you must provide these additional arguments:

  • --automated-backup-encryption-key=KEY_ID: The ID of the CMEK key to use.
  • --automated-backup-encryption-keyring=KEYRING_ID: The ID of the key's keyring.
  • --automated-backup-encryption-location=LOCATION_ID: The ID of that keyring's region. Note that it must match the cluster's region.
  • --automated-backup-encryption-project=PROJECT_ID: The keyring's project ID.

Note that using CMEK with AlloyDB requires some additional setup. For more information, see Using CMEK with AlloyDB.

Clear an automatic backup schedule

gcloud

To use the gcloud CLI, you can install and initialize the Google Cloud CLI, or you can use Cloud Shell.

Use the gcloud beta alloydb beta alloydb clusters command to clear the automatic backup schedule set on an AlloyDB cluster.

gcloud beta alloydb clusters update CLUSTER_ID \
    --clear-automated-backup \
    --region=REGION_ID \
    --project=PROJECT_ID
  • CLUSTER_ID: The ID of the cluster whose automatic backup schedule you want to clear.
  • REGION_ID: The ID of the region where the cluster is placed.
  • PROJECT_ID: The ID of the project where the cluster is placed.

For example:

gcloud beta alloydb clusters update my-cluster \
    --clear-automated-backup \
    --region=us-central-1 \
    --project=my-project