Skip to content

Backup encryption keys — managing them so the backup is actually recoverable

Encrypted backups are only useful if you still hold the key when the original host is gone. Here is how managed environments handle key custody and rotation.

A familiar near-miss: a customer’s primary database host is wiped by a bad provisioning script. The off-host backups are intact, encrypted with AES-256-GCM, copied to a separate region. The decryption passphrase was in a .env file on the host that just got wiped. The backup is technically a backup; functionally, it’s a ciphertext archive nobody can open.

What’s happening

Three failure modes that turn an encrypted backup into a brick:

  • The key lived on the host that died. Restic password in /root/.restic-pass, GPG private key in /etc/backup/gpg/, KMS credentials cached in an instance role that no longer exists. The blast radius of the original incident took the key with the data.
  • Nobody rotated the passphrase after the engineer who set it up left. It still works, but the recovery runbook references a 1Password vault that was decommissioned six months ago. No one alive in the team knows the passphrase.
  • Per-environment keys were never separated. Staging and production share one passphrase. A staging compromise is now a production backup compromise.

Encryption is a control that protects the backup at rest. It is not a substitute for key custody. The two have to be designed together or the backup is theatre.

How to verify

Audit questions a senior operator asks during onboarding, with the commands behind them:

# 1. Where does the key actually live? It must NOT be the host being backed up.
aws kms describe-key --key-id alias/backup-prod-customerA
gpg --list-secret-keys --keyid-format LONG

# 2. Can you decrypt a known archive right now, on a clean host?
gpg --decrypt /tmp/backup-test.tar.gz.gpg | tar tzf - | head

# 3. When was the key last rotated? When does it expire?
aws kms list-key-rotations --key-id alias/backup-prod-customerA
gpg --list-keys --with-colons | awk -F: '/^pub/ {print $5, $7}'

If any of the three answers is “I don’t know,” the backup’s recoverability is unverified.

The fix

The custody model we run on managed environments:

  1. Keys live off the host. KMS (AWS, GCP, Azure) for cloud-native workloads — the IAM role of the restore host grants Decrypt to a key the source host can only Encrypt against. For self-hosted, GPG private keys live in a separate, access-controlled vault, never on the source.
  2. Per-environment keys. Production, staging, and dev each get their own key. A staging breach cannot decrypt a production archive.
  3. Annual rotation, documented. New key issued, archives re-encrypted on the next full cycle, old key kept read-only for the retention window of pre-rotation backups, then revoked. The rotation event is logged.
  4. Recovery test = restore + decrypt + verify. A drill that doesn’t include opening the ciphertext is testing the wrong thing.

Stack Harbor designs key custody and runs decryption-verified drills as part of environment management. If “where is the passphrase” doesn’t have a clean answer in your runbook, we can audit and fix it.