> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tenetlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Backup and restore

> What to back up and why: the Aurora vault (short-lived sessions plus the wrapped key-pair keyring), the Object Lock audit bucket (the durable record of rehydrations and erasures), and the KMS key both depend on. Restore steps and DR choices.

**Backup scope**: the vault is short-lived working state, the audit bucket is the system of record, and your KMS key is the one thing you can never lose — without it neither can be read.

## When to use it

When you set backup and retention policy, plan DR, and before any destructive change to the database or the key.

## What lives where

| Store | Holds | Lifetime | If you lose it |
| - | - | - | - |
| **Aurora vault** | Per session: each original value sealed with HPKE to the current key pair's public key, and a keyed digest per value for dedupe. The **keyring** in `tenet_pii_vault_meta`: per key pair the public key, the lookup key and private key wrapped by your CMK, plus the current-key pointer, the deployment-id stamp and the `hpke-v3` format marker | Session rows: sliding TTL, 1 h by default. Keyring: forever. | Live sessions can't be re-identified. The detect service starts a fresh keyring on an empty database; new traffic is unaffected. |
| **S3 audit bucket** | One record per re-identify call (`tenet.reidentify-audit.v3`, under `rehydrate/` by default) and one per erasure (`tenet.erasure-audit.v1`, under `erasure/`) | Object Lock retention (templates: 2190 days) | Your evidence of who re-identified or erased what, and when. Object Lock prevents deletion; protect it from account-level loss with replication. |
| **KMS CMK** | Wraps every vault lookup and private key; encrypts Aurora, the audit bucket, logs and secrets in the templates | Until you delete it | **Everything above becomes unreadable.** Tenet has no copy and can't help. |

## Vault backups

* **Aurora automated backups** are on by default, encrypted with the CMK, in your account and Region. Point-in-time restore covers the retention window you set on the cluster.
* **`VaultDeletionPolicy=Snapshot`** (CloudFormation) or **`vault_final_snapshot = true`** (Terraform) leaves a final snapshot when the stack is deleted.
* The vault is usually **rebuildable**: sessions expire within the TTL, so after a loss, clients start new sessions. What you lose is the ability to re-identify text de-identified during the TTL window before the loss. Size backup effort to how much that window matters to you.
* **A backup holds no readable values on its own.** Sealed values open only with a private key, and private keys are stored wrapped by your CMK, which only the rehydrate role may use to unwrap them.

## Restore the vault

A snapshot restore brings back the keyring too. It works only with the **same CMK** and the **same deployment id** — both are bound into every wrapped key's encryption context, and the deployment id is stamped in the vault.

```bash theme={null}
aws rds restore-db-cluster-to-point-in-time --region "$AWS_REGION" \
  --source-db-cluster-identifier <vault-cluster> --db-cluster-identifier <vault-cluster>-restored \
  --restore-to-time 2026-11-06T08:00:00Z \
  --db-subnet-group-name <vault-subnet-group> --vpc-security-group-ids <vault-db-sg> \
  --kms-key-id <cmk-arn> --serverless-v2-scaling-configuration MinCapacity=0.5,MaxCapacity=8
aws rds create-db-instance --region "$AWS_REGION" --db-instance-identifier <vault-cluster>-restored-1 \
  --db-cluster-identifier <vault-cluster>-restored --db-instance-class db.serverless --engine aurora-postgresql
aws rds wait db-instance-available --db-instance-identifier <vault-cluster>-restored-1
```

Then point both services at the restored writer endpoint and roll them:

* **Helm:** `vault.url`, then `helm upgrade`.
* **CloudFormation / Terraform:** `CreateVaultDatabase=false` with `ExistingVaultEndpoint`, `ExistingVaultSecretArn`, `ExistingVaultSecurityGroupId` (or the `existing_vault_*` variables). Switching an existing stack from a created to an external database replaces resources — test it on a non-production stack first.

Sessions whose TTL lapsed after the restore point are expired by the vault on first touch.

Rehearse a vault restore in a non-production environment and prove old sessions still restore.

Rehearse a Tenet PII Engine (Enterprise) vault restore in my NON-production environment, following [https://docs.tenetlabs.com/pii-engine/operate/backup-restore](https://docs.tenetlabs.com/pii-engine/operate/backup-restore.md).

Ask me for: the environment name and confirm it is not production; Region; the Aurora cluster identifier, its subnet group and security group; the CMK ARN; the deployment id; platform and how the services get the vault endpoint (Helm vault.url, or CloudFormation/Terraform existing-vault inputs); the detect and rehydrate endpoints and a host running as a role allowed to call both, with the tenet-pii-lattice client installed. If I say it is production, stop.

1. Create a session with `python -m tenet_pii_lattice <detect endpoint> deidentify` on synthetic text and keep its text and session\_id. If the session TTL is shorter than this rehearsal will take, tell me before continuing.
2. Note the current time T, wait two minutes, and restore the cluster to T with `aws rds restore-db-cluster-to-point-in-time` using the same CMK, then create a db.serverless instance and wait for it to be available.
3. Show me the change that points the services at the restored endpoint, keeping the same deployment id and CMK, and wait for my approval before applying it and rolling both services.
4. Verify readiness (ECS: running = desired and every Lattice target HEALTHY; EKS: `tenet-pii-enterprise healthcheck --ready` exec'd in each Deployment exits 0) and that `python -m tenet_pii_lattice <rehydrate endpoint> reidentify <session_id>` restores the step-1 text.
5. Ask me before deleting the restored cluster.
   Report timings for each step.

## Audit bucket

* **Retention** is the bucket's Object Lock default (`AuditRetentionDays` / `audit_retention_days`, 2190 days). In `COMPLIANCE` mode nobody can shorten it.
* **Two writers, two prefixes.** Rehydrate writes reidentify records under `AuditPrefix` / `audit_prefix` (default `rehydrate/`); detect writes erasure records under `ErasureAuditPrefix` / `erasure_audit_prefix` (default `erasure/`). Back up and replicate both.
* **Copies:** for protection against account or Region loss, add S3 replication to a bucket in another account or Region that also has Object Lock enabled. The templates don't configure replication.
* **Restores** aren't needed — objects can't be deleted or overwritten during retention. If you suspect tampering, compare object versions and retention with `aws s3api list-object-versions` and `get-object-retention`.
* **Stack deletes keep the bucket** (`DeletionPolicy: RetainExceptOnCreate`; Terraform `prevent_destroy`).

## The KMS key

* Never schedule deletion of the CMK while any vault snapshot or audit object you need is encrypted under it.
* Restrict `kms:ScheduleKeyDeletion` and `kms:DisableKey` to break-glass administrators, and alarm on them in CloudTrail.
* Automatic KMS key rotation is safe to turn on.

## Disaster recovery

Vault data is short-lived, so DR is usually **a second deployment, not a replica**: deploy the stack in the recovery Region with its own deployment id and vault, and fail clients over. Sessions in flight at the time of failover can't be re-identified in the new Region; clients start new sessions. Callers in the recovery Region need their own Lattice service network association, invoker-list entries and caller policies there. Keep the audit bucket's replica in the recovery Region if you replicate it.

## Gotchas

* **A restored vault with a different deployment id won't start.** The keyring stamps the id, and a mismatch is refused at startup.
* **The Aurora master secret rotates** (CloudFormation default, 7 days). After restore or rotation, restart both services so they pick up current credentials.
* **Deleting a session is permanent.** `DELETE /sessions/{session_id}` removes it from the live vault (after writing its erasure record); it remains only in backups until they age out — account for that in erasure requests.

## Links

* [Key rotation](https://docs.tenetlabs.com/pii-engine/operate/key-rotation.md)
* [Upgrades](https://docs.tenetlabs.com/pii-engine/operate/upgrades.md)
* [Shared responsibility](https://docs.tenetlabs.com/pii-engine/security/shared-responsibility.md)
* [Rehydration and audit](https://docs.tenetlabs.com/pii-engine/concepts/rehydration-and-audit.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.