Manage backups

This page describes how to perform Memorystore for Valkey backup operations. Before you read this page, ensure that you're familiar with backups.

Before you begin

  1. Make sure that either you or the user account that you're using have the required permissions for the action you need to perform.

    The Memorystore Admin and Memorystore Editor roles can perform all backup operations. The Memorystore Viewer role can view and export backups.

  2. Install and update the Google Cloud CLI.

Create an on-demand backup

To create an on-demand backup, use the gcloud memorystore instances backup command.

gcloud

gcloud memorystore instances backup INSTANCE_ID \
--backup-id=BACKUP_ID \
--ttl=TTL_PERIOD

Replace the following:

  • INSTANCE_ID: the ID of the Memorystore for Valkey instance.
  • BACKUP_ID: an ID for the backup, such as march-2025-backup.
  • TTL_PERIOD: a time to live (TTL) for the backup. After the backup reaches the TTL limit, Memorystore for Valkey deletes the backup automatically.

    You set the value for this parameter to a number of days (for example, 14d). The minimum value is 1 day. If you don't specify a value, then the default value is 100 years.

The command returns an operation name with the following format:

projects/PROJECT_ID/locations/REGION_ID/operations/operation-UID

To check the status of an operation, use the gcloud memorystore operations describe command.

gcloud memorystore operations describe projects/PROJECT_ID/locations/REGION_ID/operations/operation-UID

To list all operations in a project and region, use the gcloud memorystore operations list command.

gcloud memorystore operations list --projects=PROJECT_ID \
--location=REGION_ID

Configure automated backup schedules

You can configure a daily backup schedule when you create an instance or you can enable a daily backup schedule on an existing instance.

Create an instance with an automated backup schedule enabled

The following example demonstrates how to set a daily backup schedule as you create an instance. For more options that are available when creating instances, see Create an instance.

gcloud

gcloud memorystore instances create INSTANCE_ID \
--automated-backup-mode=ENABLED \
--automated-backup-start-time=START_TIME \
--automated-backup-ttl=RETENTION_POLICY

Replace the following:

  • INSTANCE_ID: the ID of the Memorystore for Valkey instance that you're creating.
  • START_TIME: the time when Memorystore for Valkey begins taking backups. Specify the time in the HH format on a 24-hour cycle in UTC time. For example: 23.
  • RETENTION_POLICY: the number of days for which Memorystore for Valkey retains each backup. Set the value for this parameter to a number of days (for example, 7d). The maximum value is 365 days and the default value is 35 days.

    Even after you delete the instance, Memorystore for Valkey retains the backup for the retention period, with a maximum of 365 days. To remove the backup before the retention period expires, you must delete the backup manually.

Enable scheduled backups on an existing instance

To enable scheduled backups on an instance, use the gcloud memorystore instances update command.

gcloud

gcloud memorystore instances update INSTANCE_ID \
--automated-backup-mode=enabled \
--automated-backup-start-time=START_TIME \
--automated-backup-ttl=RETENTION_POLICY

Replace the following:

  • INSTANCE_ID: the ID of the Memorystore for Valkey instance that you're updating.
  • START_TIME: a timestamp that specifies when Memorystore for Valkey begins taking backups. This timestamp must be at the hour level, in the HH format, and on a 24-hour cycle in UTC time (for example, 23). The timestamp also designates a one-hour window of when Memorystore for Valkey begins to take backups.
  • RETENTION_POLICY: the number of days for which Memorystore for Valkey retains each backup. Set the value for this parameter to a number of days (for example, 7d).

    Even after you delete the instance, Memorystore for Valkey retains the backup for the retention period. To remove the backup before the retention period expires, you must delete the backup manually.

Deactivate scheduled backups on an existing instance

To deactivate scheduled backups on an instance, use the gcloud memorystore instances update command.

gcloud

gcloud memorystore instances update INSTANCE_ID \
--automated-backup-mode=disabled

Replace INSTANCE_ID with the ID of the Memorystore for Valkey instance that you're updating.

Concurrency with update instance, maintenance, and backup operations

Update operations on an instance and maintenance operations can cancel ongoing backup operations in the following situations:

  • If there's an ongoing operation to update an instance, then Memorystore for Valkey rejects backup operation requests.
  • If there's an ongoing backup operation, then Memorystore for Valkey rejects an incoming operation to update an instance.
  • Maintenance and backup operations might coincide with each other. If this occurs, then Memorystore for Valkey skips the backup operations for that instance.

List and describe backups

The following sections demonstrate how to find information about backups.

List backup collections

A backup collection contains all backups for a Memorystore for Valkey instance. To list backup collections for a project and region, use the gcloud memorystore backup-collections list command.

gcloud

gcloud memorystore backup-collections list \
--project=PROJECT_ID \
--location=REGION_ID

Replace the following:

  • PROJECT_ID: your project ID
  • REGION_ID: the region where your instance is located (for example, us-east1)

The command returns a list of backup collections.

List the backups in a backup collection

To list the backups in a backup collection, use the gcloud memorystore backup-collections backups list command.

gcloud

gcloud memorystore backup-collections backups list \
--backup-collection=BACKUP_COLLECTION
--project=PROJECT_ID \
--location=REGION_ID

Replace the following:

  • BACKUP_COLLECTION: the name of the backup collection
  • PROJECT_ID: your project ID
  • REGION_ID: the region where your instance is located (for example, us-east1)

The command returns a list of backups that are in a backup collection.

Describe a backup

To retrieve information about a backup, use the gcloud memorystore backup-collections backups describe command.

gcloud

gcloud memorystore backup-collections backups describe BACKUP_NAME \
--backup-collection=BACKUP_COLLECTION \
--project=PROJECT_ID \
--location=REGION_ID

Replace the following:

  • BACKUP_NAME: the name of the backup (for example, 2024-05-01-10-15-00)
  • BACKUP_COLLECTION: the name of the backup collection
  • PROJECT_ID: your project ID
  • REGION_ID: the region where your instance is located (for example, us-east1)

The command returns information about the backup that's 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'
instance: projects/PROJECT_ID/locations/us-east1/instances/instance1
instanceUid: 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/march-2025-backup
nodeType: HIGHMEM_MEDIUM
shardCount: 3
state: ACTIVE
totalSizeBytes: '2084589755'

Delete a backup

To delete a backup, use the gcloud memorystore backup-collections backups delete command.

gcloud

gcloud memorystore backup-collections backups delete BACKUP_NAME \
--backup-collection=BACKUP_COLLECTION \
--project=PROJECT_ID \
--location=REGION_ID

Replace the following:

  • BACKUP_NAME: the name of the backup (for example, 2024-05-01-10-15-00)
  • BACKUP_COLLECTION: the name of the backup collection
  • PROJECT_ID: your project ID
  • REGION_ID: the region where your instance is located (for example, us-east1)

Export a backup to a storage bucket

You can export a backup to a Cloud Storage bucket.

The following steps demonstrate how to export a backup.

  1. Grant the Memorystore for Valkey service agent access to Cloud Storage's resources.

    You grant the service agent access to Cloud Storage's resources so that Memorystore for Valkey can access the destination Cloud Storage bucket. Also, the Memorystore for Valkey service agent uses the following naming format:

    service-PROJECT_NUMBER@gcp-sa-memorystore.iam.gserviceaccount.com
    

    Replace PROJECT_NUMBER with the project number of the project where the instance or backup is located.

    Grant the service agent a role that assigns the storage.buckets.get, storage.objects.create, storage.objects.delete, and storage.folders.create permissions to the role.

    For example, the following command assigns the Storage Admin role to the service agent for a Cloud Storage bucket:

    gcloud

    gcloud storage buckets add-iam-policy-binding gs://BUCKET_NAME \
    --member=serviceAccount:service-PROJECT_NUMBER@gcp-sa-memorystore.iam.gserviceaccount.com \
    --role=roles/storage.admin
    

    Replace the following:

    • BUCKET_NAME: the name of the destination Cloud Storage bucket. This bucket must be a regional bucket and it must be in the same region as the backup. Memorystore for Valkey must have permissions to access the bucket and to create folders and objects inside of the bucket.
    • PROJECT_NUMBER: the project number that's used in the service agent name.
  2. To export a backup to a Cloud Storage bucket, use the gcloud memorystore backup-collections backups export command.

    gcloud

    gcloud memorystore backup-collections backups export BACKUP_NAME \
    --backup-collection=BACKUP_COLLECTION \
    --location=REGION_ID \
    --gcs-bucket=BUCKET_NAME
    

    Replace the following:

    • BACKUP_NAME: the name of the Memorystore for Valkey backup
    • BACKUP_COLLECTION: the name of the backup collection
    • REGION_ID: the region where the backup collection is located (for example, us-east1)
    • BUCKET_NAME: the name of the Cloud Storage bucket

Restore data from a backup

To restore data from a backup, you can either seed a new instance from a managed backup in the same project or you can seed a new instance from RDB files in a Cloud Storage bucket. To seed an instance from RDB files, Memorystore for Valkey must have permissions to access the files.

Seed a new instance from a backup

The following example demonstrates how to import data from a backup into a new instance. The backup must be in the same region as the instance. Also, the principal that creates the instance must have the redis.backups.get permission for the backup.

gcloud

gcloud memorystore instances create INSTANCE_ID \
--import-managed-backup=BACKUP_NAME \
--location=REGION_ID

Replace the following:

  • INSTANCE_ID: the ID of the Memorystore for Valkey instance that you're creating.
  • BACKUP_NAME: the name of the backup. This name has the following format: projects/PROJECT_ID/locations/REGION_ID/backupCollections/BACKUP_COLLECTION_ID/backups/BACKUP_ID.
  • REGION_ID: the region where your instance is located (for example, us-east1).

Seed a new instance from RDB files in a storage bucket

You can import data from RDB files, which are contained in a Cloud Storage bucket, into a new instance.

The following steps demonstrate how to import data from RDB files in a Cloud Storage bucket to a new instance.

  1. Grant the Memorystore for Valkey service agent access to Cloud Storage's resources.

    You grant the service agent access to Cloud Storage's resources so that Memorystore for Valkey can access the RDB files that are in the Cloud Storage bucket. Also, the Memorystore for Valkey service agent uses the following naming format:

    service-PROJECT_NUMBER@gcp-sa-memorystore.iam.gserviceaccount.com

    Replace PROJECT_NUMBER with the project number of the project where you create the new instance.

    Grant the service agent a role that assigns the storage.buckets.get and storage.objects.get permissions to the role.

    For example, the following command assigns the Storage Admin role to the service agent for a Cloud Storage bucket:

    gcloud

    gcloud storage buckets add-iam-policy-binding gs://BUCKET_NAME
    --member=serviceAccount:service-PROJECT_NUMBER@gcp-sa-memorystore.iam.gserviceaccount.com
    --role=roles/storage.admin
    

    Replace the following:

    • BUCKET_NAME: the name of the bucket where the RDB files are located. This bucket must either be a regional bucket in the same region as the backup, or be a dual-region bucket and have one region be the same as the backup. Memorystore for Valkey must have permissions to access the bucket.
    • PROJECT_NUMBER: the project number that's used in the service agent name.
  2. To import data from RDB files in a Cloud Storage bucket into a new instance, use the gcloud memorystore instances create command.

    gcloud

    gcloud memorystore instances create INSTANCE_ID \
    --import-gcs-object-uris=URI \
    --location=REGION_ID
    

    Replace the following:

    • INSTANCE_ID: the ID of the Memorystore for Valkey instance that you're creating.
    • URI: one or more Cloud Storage uniform resource identifiers (URIs) that are separated by commas. For example: gs://my-bucket/folder/file1.rdb,gs://my-bucket/folder/file2.rdb.
    • REGION_ID: the region where your instance is located (for example, us-east1).

Cloud Monitoring metrics

To monitor recent backup and import operations, you can use Cloud Monitoring metrics. For a list of metrics that are available for Memorystore for Valkey backups, see Backup metrics.