Secret Manager backup and restore lets you create point-in-time snapshots to help protect your regional secrets against accidental or malicious deletion and data corruption. When you delete a regional secret in Secret Manager, you permanently lose all its versions and metadata. You can use backups to restore that data to a new secret.
This document is for backup and disaster recovery administrators who manage backups and restores of secrets across your organization.
Secret backup overview
A secret backup is a copy of a secret's metadata and all its versions from the time that you create the backup. Backups are regional resources that remain in the region that you specify when you create them. You can create backups in the same region as your secret or in another supported region to reduce the risk of data loss.
You can back up only secrets that aren't associated with a secret type.
After you create a backup, you can modify or delete the source secret without affecting the backup.
Secret backup and restore locations
Secret backup and restore is supported in the following regions:
asia-northeast2(Osaka)asia-south2(Delhi)europe-west1(Belgium)europe-west3(Frankfurt)northamerica-northeast2(Toronto)us-east5(Columbus)us-west2(Los Angeles)
The following location rules apply when you back up and restore secrets:
- Source secrets: You can back up global secrets and regional secrets that are stored in a supported region.
- Backups: Backups are stored in a supported region, even when you
back up a global secret. You can store a backup in the same region as the
source secret or in a different supported region. You can't store backups in
globalor in multi-region locations. - Restored secrets: You can restore a backup to a new global secret by using an automatic replication policy. You can also restore a backup to a new regional secret in a supported region. In either case, you can restore the backup to the same project or a different project.
- Encryption keys: If you encrypt a restored secret with a
customer-managed encryption key (CMEK), the key location must
match the destination secret. For a global secret, the key must be in
global. For a regional secret, the key must be in the same region as the destination secret.
Use cases
A backup is a recovery point that's independent of the source secret. Even if the secret is deleted, or the region that stores it is unavailable, you can bring the secret back. Because you choose where to restore a backup, you can also use backups to move secrets to a new location, replication policy, or Google Cloud project. The following sections describe some common use cases.
Recover from accidental or malicious deletion
Deleting a secret is permanent: Secret Manager removes the secret, all of its versions, and its metadata, and you can't undo the deletion. Destroying a secret version is also irreversible. With a backup, you can restore the secret, including the payloads of all versions that were enabled or disabled when you created the backup.
For example, a cleanup script deletes a database password that a production service still uses. Instead of rotating the credential in every dependent system, you restore the secret from the previous day's backup and get the same password back.
Create a restore point before risky changes
Before you make a change that's hard to undo, create a backup of the affected secrets. Examples of such changes include destroying old secret versions, running a bulk cleanup script, or changing how your rotation automation adds versions. If the change goes wrong, restore the backup to revert the secret to its previous state. The restored secret includes the payloads of versions that you destroyed after creating the backup.
Recover from a regional outage
A regional secret stores its data in a single region. To help protect a regional secret against an outage in that region, create backups in a different supported region. If the source region becomes unavailable, restore the backup to a new regional secret in another region, or to a global secret. Then, update your workloads to use the restored secret.
For example, you store a payment API key as a regional secret in
us-east5 and back it up to us-west2. If
us-east5 has an outage, you restore the backup to a regional
secret in us-west2.
Help protect against the loss of an encryption key
If you encrypt a secret with a CMEK and that key is disabled or destroyed, you can't access the secret data. When you create a backup, Secret Manager encrypts the backup with a Google-owned and Google-managed encryption key. You can restore the backup even if the key of the source secret is no longer available.
You can't encrypt backups with a CMEK.
Investigate an incident
To find out what a secret contained at a specific point in time, restore a backup to a temporary secret and inspect its versions. The live secret isn't affected. After your investigation, delete the temporary secret.
Change the location or ID of a secret
You can't change the location or ID of a secret after you create it. When you restore a backup, you choose the destination, so you can use backup and restore to move a secret in the following ways:
- Restore a global secret as a regional secret, for example, to keep the secret data in a single region to help meet data residency requirements.
- Restore a regional secret as a global secret, for example, to let Secret Manager manage replication of the secret data for you.
- Restore a global secret that uses a user-managed replication policy as a global secret with an automatic replication policy.
- Restore a secret with a new secret ID, for example, to adopt a new naming convention.
Restoring a backup creates a new secret and doesn't change the source secret. After you verify the restored secret, update your applications to use it, and then delete the source secret if you no longer need it.
Copy secrets across projects
You can restore a backup to a different project and give the restored secret a new ID. For example, when you reorganize your resources, you can move secrets to a new project without reading secret payloads or handling them in scripts. The secret data stays in Secret Manager throughout the process.
A restored secret doesn't keep the Identity and Access Management (IAM) policy, rotation schedule, expiration settings, or Pub/Sub notification topics of the source secret. After you restore a backup, configure these settings on the new secret.
Back up a secret
Each backup is a full point-in-time snapshot. The following table describes the data that's preserved during a backup and restore:
| Preserved on restore | Not preserved on restore |
|---|---|
Secret metadata: labels, annotations, version aliases, and the
delayed destruction
setting (versionDestroyTtl) |
Expiration settings (expireTime and ttl),
rotation schedules, Pub/Sub notification topics, and
IAM policies |
Version metadata: version numbers and states (ENABLED,
DISABLED, or DESTROYED) |
Source CMEK settings. You choose the destination location and an optional CMEK when you restore the backup. |
Payload data for ENABLED and DISABLED
versions |
Payload data for versions that were destroyed before you created the backup |
To back up a regional secret, see Create a backup of a regional secret.
Backup deletion
A secret backup is a project-level resource with its own storage. As a result, a secret backup's lifecycle isn't associated with the source secret. Deleting a secret doesn't affect the backup.
To delete a backup, you must delete the backup itself. This action is permanent and irreversible.
To delete a backup of a regional secret, see Delete a regional secret backup.
Backup expiration
Backups are temporary resources. By default, secret backups expire after 180 days. When a backup expires, Secret Manager deletes the backup.
Secret restoration
When you restore a backup, Secret Manager creates a new secret that contains the data from the backup. You can't overwrite an existing secret.
You can restore a backup to a new global secret by using an automatic
replication policy. You can also restore a backup to a new regional secret in
a supported region. In
either case, you can restore the backup to the same project or a different
project. While the restoration is in progress, the new secret is in the
STATE_RESTORING state, and Secret Manager temporarily
blocks read and write operations on it.
To restore a regional secret, see Restore a regional secret.
Pricing
You can use secret backup and restore at no charge during Preview. For pricing details, see Secret Manager pricing.
What's next
- Learn how to create a regional secret backup.
- Learn how to list regional secret backups.
- Learn how to restore a regional secret backup.
- Learn how to update a regional secret backup.
- Learn how to delete a regional secret backup.