This page describes how to perform Memorystore for Redis Cluster backup operations. Before you read this page, you should be familiar with Backups.
Before you begin
Make sure that you or the user account that you are using have the required permissions for the action you need to perform.
The Redis Admin and Redis Editor roles can perform all backup operations. The Redis Viewer role can view and export backups.
Initiate an on-demand backup
Use the following command to take an on-demand backup:
gcloud
gcloud beta redis clusters create-backup INSTANCE_ID \ --backup-id=BACKUP_ID \ --ttl=TTL_PERIOD
Replace the following:
- INSTANCE_ID is the ID of the Memorystore for Redis Cluster instance.
- BACKUP_ID is an ID for the backup such as
december-2024-backup
- TTL_PERIOD specifies a time to live (TTL) for the backup.
The backup is automatically deleted after reaching the TTL limit.
Set to a number of days. For example,
14d
. The minimum value is 1 day. If not specified, the default value is 100 years.
The command returns an operation name with the following format:
projects/PROJECT_ID/locations/REGION/operations/operation-UID
You can use the
gcloud redis operations describe
command to check the status of an operation:
gcloud redis operations describe projects/PROJECT_ID/locations/REGION/operations/operation-UID
You can also use the
gcloud redis operations list
command to list all operations in a project and region.
Configure automated backup schedules
You can configure a daily backup schedule when you create a new cluster or you can enable a daily backup schedule on an existing cluster.
Create a cluster with an automated backup schedule enabled
The following example demonstrates how to set a daily backup schedule as you create a new cluster. For more options available when creating clusters, see Create an instance.
gcloud
gcloud beta redis clusters create INSTANCE_ID \ --automated-backup-mode=ENABLED \ --automated-backup-start-time=START_TIME \ --automated-backup-ttl=RETENTION_POLICY
Replace the following:
- INSTANCE_ID is the ID of the Memorystore for Redis Cluster instance you're creating.
- START_TIME A specifies when to begin taking backups. Specify
the time in the format
HH:00
on a 24-hour cycle in UTC time. For example,23:00
. RETENTION_POLICY specifies how many days to retain each backup. Set to a number of days, for example,
7d
. The maximum is 365 days and the default is 35 days.Even after a cluster is deleted, the backup is retained for the retention period with a maximum of 365 days. You must manually delete the backup to remove the backup before the retention period expires.
Enable scheduled backups on an existing cluster
gcloud
gcloud beta redis clusters update INSTANCE_ID \ --automated-backup-mode=enabled \ --automated-backup-start-time=START_TIME \ --automated-backup-ttl=RETENTION_POLICY
Replace the following:
- INSTANCE_ID is the ID of the Memorystore for Redis Cluster instance you're updating.
START_TIME A timestamp that specifies when to begin taking backups. The timestamp must be at the hour level and designates a one hour window when backups begin, for example,
2024-01-01T01:00:00Z
.RETENTION_POLICY specifies how many days to retain each backup. Set to a number of days, for example,
7d
.Even after a cluster is deleted, the backup is retained for the retention period. You must manually delete the backup to remove the backup before the retention period expires.
Disable scheduled backups
Use the following command to disable scheduled backups on a cluster:
gcloud
gcloud beta redis clusters update INSTANCE_ID \ --automated-backup-mode=disabled
Replace INSTANCE_ID with the ID of the Memorystore for Redis Cluster instance you're updating.
Concurrency between backup and update cluster operations
Updates operations on a cluster and maintenance operations can cancel ongoing backup operations in the following situations:
- If there is an ongoing operation to update a cluster, backup operations requests are rejected.
- If there is an ongoing backup operation, an incoming operation to update a cluster might cancel and fail the ongoing backup operation.
- In rare circumstances, maintenance and backup operations might coincide with each other and lead to the backup operations being skipped for that instance.
List and describe backups
The following sections demonstrate how to find information about available backups.
List backup collections
A backup collection includes all backups under a cluster. Use the following command to list backup collections in the specified project and region:
gcloud
gcloud beta redis clusters backup-collections list \ --project=PROJECT_ID \ --region=REGION
Replace the following:
- REGION is the region where your cluster is located such as
us-east1
. - PROJECT_ID is your project ID.
The command returns a list of backup collections similar to the following:
BACKUP_COLLECTION_NAME CLUSTER_NAME CLUSTER_UID 6d9e1ff4-0f89-4c0a-a941-155dd4c3a213 projects/PROJECT_ID/locations/REGION/clusters/cluster1 6e539aed-ee7b-4eea-83ad-b4715b1ef160 dda2f551-b416-47ff-b1cf-684e00483dc9 projects/PROJECT_ID/locations/REGION/clusters/cluster2 57130520-636c-4ac7-ad7e-86f7cfb32838
List backups under a backup collection
Use the following command to list backups in a backup collection:
gcloud
gcloud beta redis clusters backups list \ --backup-collection=BACKUP_COLLECTION --project=PROJECT_ID \ --region=REGION
Replace the following:
- BACKUP_COLLECTION is the name of a backup collection.
- REGION is the region where your cluster is located such as
us-east1
. - PROJECT_ID is your project ID.
The command returns a list of backups similar to the following:
BACKUP_NAME STATE CREATE_TIME EXPIRE_TIME backup-1 ACTIVE 2024-11-10T03:52:40.899882388Z 2124-11-10T03:53:02.856981736Z backup-2 ACTIVE 2024-11-11T03:48:22.137134936Z 2124-11-11T03:48:44.130735425Z
Describe a backup
Use the following command to retrieve information about a specific backup:
gcloud
gcloud beta redis clusters backups describe BACKUP_NAME \ --backup-collections=BACKUP_COLLECTION --project=PROJECT_ID \ --region=REGION
Replace the following:
- BACKUP_NAME is the name of a backup such as
2024-05-01-10-15-00
. - BACKUP_COLLECTION is the name of a backup collection.
- REGION is the region where your cluster is located such as
us-east1
. - PROJECT_ID is your project ID.
The command returns information about the backup similar to the following:
backupFiles: - createTime: '2024-11-10T03:52:55.539Z' fileName: 3d2774dab822137c5bac9386f3fa69ee4c73b928.rdb sizeBytes: '694879680' - createTime: '2024-11-10T03:52:54.742Z' fileName: 7f5d99faaefc63ed8292a71da2552db3b06cdcff.rdb sizeBytes: '694925906' - createTime: '2024-11-10T03:52:54.972Z' fileName: 0aac1092a3fb81515aefb6b2421f31eb346c3961.rdb sizeBytes: '694784169' cluster: projects/PROJECT_ID/locations/us-east1/clusters/cluster1 clusterUid: 57130520-636c-4ac7-ad7e-86f7cfb32838 createTime: '2024-11-10T03:52:40.899882388Z' expireTime: '2124-11-10T03:53:02.856981736Z' name: projects/PROJECT_ID/locations/us-east1/backupCollections/dda2f551-b416-47ff-b1cf-684e00483dc9/backups/december-2024-backup nodeType: REDIS_HIGHMEM_MEDIUM shardCount: 3 state: ACTIVE totalSizeBytes: '2084589755'
Delete a backup
Use the following command to delete a backup:
gcloud
gcloud beta redis clusters backups delete BACKUP_NAME \ --backup-collection=BACKUP_COLLECTION --project=PROJECT_ID \ --region=REGION
Replace the following:
- BACKUP_NAME is the name of a backup such as
2024-05-01-10-15-00
. - BACKUP_COLLECTION is the name of a backup collection.
- REGION is the region where your cluster is located such as
us-east1
. - PROJECT_ID is your project ID.
Export a backup to a storage bucket
You can export a backup to a Cloud Storage bucket. The destination bucket must be a regional bucket and it must be in the same region as the backup. Memorystore for Redis Cluster must have permission to access the Cloud Storage bucket and to create folders and objects inside the bucket.
The following steps demonstrate how to export a backup.
Memorystore for Redis Cluster must have permission to access the destination Cloud Storage bucket. Grant the Memorystore for Redis Cluster service agent access to the Cloud Storage resources.
The Memorystore for Redis Cluster service agent uses the following naming format:
service-PROJECT_NUMBER@cloud-redis.iam.gserviceaccount.com
Replace PROJECT_NUMBER with the project number of the project where the cluster or backup is located.
Grant the service agent a role that gives the
storage.buckets.get
,storage.objects.create
,storage.objects.delete
, andstorage.folders.create
permissions. For example, the following command grants theStorage Admin
role for the specified bucket to the Memorystore for Redis Cluster service agent:gcloud
gcloud storage buckets add-iam-policy-binding gs://BUCKET_NAME \ --member=serviceAccount:service-PROJECT_NUMBER@cloud-redis.iam.gserviceaccount.com \ --role=roles/storage.admin
Replace the following:
- BUCKET_NAME is the name of the destination bucket.
- PROJECT_NUMBER is the project number used in the service agent name.
Use the
gcloud beta redis clusters backups export
command to export a backup to a Cloud Storage bucket.gcloud
gcloud beta redis clusters backups export BACKUP_NAME \ --region=REGION \ --backup-collection=BACKUP_COLLECTION \ --gcs-bucket=BUCKET
Replace the following:
- BACKUP_NAME is the name of a Memorystore for Redis Cluster backup.
- BACKUP_COLLECTION is the name of a backup collection.
- REGION is the region where the backup collection is located such as
us-east1
. - BUCKET is a Cloud Storage bucket.
The bucket must be a regional bucket and it must be in the same region as the backup. Memorystore for Redis Cluster must have permission to access the Cloud Storage bucket and to create folders and objects inside the bucket.
Restore data from a backup
To restore data from a backup, you can either seed a new cluster from a managed backup in the same project or you can seed a new cluster from RDB files in a storage bucket. To seed a cluster from RDB files, Memorystore for Redis Cluster must have permission to access the files.
Seed a new cluster from a backup
The following example demonstrates how to import data from a backup to
a new cluster. The backup must be in the same region as the new cluster.
The principal creating the cluster must have redis.backups.get
permission
for the backup.
For more options available when creating clusters, see Create an instance.
gcloud
gcloud beta redis clusters create INSTANCE_ID \ --import-managed-backup=BACKUP_NAME \ --region=REGION
Replace the following:
- INSTANCE_ID is the ID of the Memorystore for Redis Cluster instance you're creating.
- BACKUP_NAME is the name of a manage backup. For example,
projects/PROJECT_ID/locations/REGION/backupCollections/BACKUP_COLLECTION_ID/backups/BACKUP_ID
. - REGION is the region where your cluster is located such as
us-east1
.
Seed a new cluster from RDB files in a storage bucket
The following example demonstrates how to import data from RDB files in a Cloud Storage bucket to a new cluster. The bucket must be a regional in the same region as the new cluster or dual-region bucket with one region the same.
To seed a cluster from RDB files in a Cloud Storage, you must grant Memorystore for Redis Cluster access to the Cloud Storage bucket and objects and then run the create operation.
Memorystore for Redis Cluster must have permission to access the Cloud Storage objects. Grant the Memorystore for Redis Cluster service agent access to the Cloud Storage resources.
The Memorystore for Redis Cluster service agent uses the following naming format:
service-PROJECT_NUMBER@cloud-redis.iam.gserviceaccount.com
Replace PROJECT_NUMBER with the project number of the project where you will create the new cluster.
Grant the service agent a role that gives the
storage.buckets.get
andstorage.objects.get
permissions. For example, the following command grants theStorage Admin
role to a Cloud Storage bucket:gcloud
gcloud storage buckets add-iam-policy-binding gs://BUCKET_NAME --member=serviceAccount:service-PROJECT_NUMBER@cloud-redis.iam.gserviceaccount.com --role=roles/storage.admin
Replace the following:
- BUCKET_NAME is the name of the bucket where the RDB files are located.
- PROJECT_NUMBER is the project number used in the service agent name.
The following example demonstrates how to import data from RDB files in a Cloud Storage bucket to a new cluster. For more options available when creating clusters, see Create an instance.
gcloud
gcloud beta redis clusters create INSTANCE_ID \ --import-gcs-object-uris=URI \ --region=REGION
Replace the following:
- INSTANCE_ID is the ID of the Memorystore for Redis Cluster instance you're creating.
- URI is one or more Cloud Storage URIs separated by commas (
,
). For example,gs://my-bucket/folder/file1.rdb,gs://my-bucket/folder/file2.rdb
. - REGION is the region where your cluster is located such as
us-east1
.
Cloud Monitoring metrics
You can use Cloud Monitoring metrics to monitor recent backup and import operations. For a list of metrics available for Memorystore for Redis Cluster backups, see Backup metrics.
What's next
- Read more about backups.
- Learn about Persistence.