Skip to main content
RunBook Academy

CephCIII · Secrets and Key ManagementSecrets and Key Management

Backing up and restoring the auth database

Advanced⏱ ~17 minceph

What you'll learn

  • Take an auth database backup
  • Store it appropriately
  • Restore a single entity
  • Restore the whole database

Prerequisites

None — start here.

Verified against Ceph Tentacle 20.2.x · Ceph Squid 19.2.x (supported previous) · cephadm matches the verified Ceph release · podman 4.x · csi-rbd and csi-cephfs current · RBD / CephFS / RGW current (matches Ceph release) · Linux kernel 5.15+ (5.10 minimum) · Ubuntu 24.04 LTS (Ceph host baseline) · Debian 12 (Bookworm) (Ceph host baseline) · Rocky Linux / RHEL / AlmaLinux 9.x (Ceph host baseline) · Proxmox VE 9.x (cross-course integration) · Kubernetes 1.31+ (cross-course integration) · 2026-08-18

Not yet marked complete on this device.

Why this matters in production

Restoring one accidentally deleted entity is a two-minute operation with a backup and a redistribution project without one.

Taking the backup

ceph auth export -o /secure/ceph-auth-$(date +%Y%m%d).export
chmod 600 /secure/ceph-auth-*.export
# per-entity, which restores more surgically
ceph auth ls --format json | python3 -c '
import sys,json
for e in json.load(sys.stdin)["auth_dump"]: print(e["entity"])' | \
while read ent; do
  ceph auth export "$ent" -o "/secure/entities/${ent}.export" 2>/dev/null
done
chmod 600 /secure/entities/*
Per-entity exports mean a single restore does not risk overwriting
entities that have legitimately changed since the backup.
head -3 /secure/entities/client.app-a.export
[client.app-a]
	key = AQ...
	caps mon = "profile rbd"
	caps osd = "profile rbd pool=app-a"

Storing it

PropertyRequirement
Locationnot on a cluster host; not in the cluster it protects
Encryption at restrequired — this is every key
Access controlthe same as any credential store
Retentionenough versions to predate a mistake
Testingrestore into a test cluster periodically
An auth backup on the cluster it backs up protects against accidental
deletion and against nothing else.

Restoring a single entity

# what exists now
ceph auth get client.app-a 2>&1 | head -2
ceph auth import -i /secure/entities/client.app-a.export
ceph auth get client.app-a
Import restores the entity with its original key, which means existing
consumers holding that key work again immediately — no redistribution.
# verify the consumer recovered
IMAGE=vm-disk-01
rbd status app-a/${IMAGE} | grep -i watcher
ScenarioRestore effect
Entity deleted by mistakeconsumers work again with no redistribution
Capabilities narrowed by mistakeoriginal caps restored
Key rotated and the new one lostthe old key is restored and works
Entity legitimately changed since backupthe change is reverted — check first

Restoring the whole database

# this overwrites; understand what it reverts before running
ceph auth import -i /secure/ceph-auth-20260801.export
Importing a whole-database export adds and updates entities from the
file. Entities created after the backup are not removed by it, and
entities modified since the backup are reverted to their backed-up
state.
# compare before importing
diff <(ceph auth ls --format json | python3 -c '
import sys,json
for e in sorted(json.load(sys.stdin)["auth_dump"], key=lambda x: x["entity"]):
    print(e["entity"], sorted(e.get("caps", {}).items()))') \
     /secure/auth-inventory-20260801.txt

Quiz

Knowledge check · 4 questions

  1. Q1. What does importing a per-entity auth export achieve that recreating the entity does not?

  2. Q2. A cluster holding only an auth export has protected its identities and nothing else the monitors know.

  3. Q3. Recover from an accidental entity deletion.

    An operator ran `ceph auth rm client.app-a` intending a different entity. The application has begun failing to authenticate.

  4. Q4. Why are per-entity exports preferable to a single whole-database export?

Passing score: 75%. Answers are checked in this browser.

Production discipline

Take per-entity auth exports, not only a whole-database one — restoring one entity then recovers its original key without reverting anything that legitimately changed. Store the export off the cluster and encrypted; it contains every key.

Cross-course references

  • Kubernetes: restoring one Secret differs from restoring an etcd snapshot
  • Linux: granular backups make recovery surgical rather than wholesale