Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

Backup & recoveryMixed 23 series

Resilience commands that prove the plan

A resilience plan is a set of claims: the backup restores, the replica promotes, the traffic moves, the service recovers. Each claim can be tested with a command, and a command is harder to argue with than a slide.

Quick reference

Four blocks, twenty commands, one timed restore.

Backup

restic snapshots --latest 3
restic check --read-data-subset=5%
pg_basebackup -D /bk -Ft -z -P
velero backup get
aws s3 ls s3://backups/prod/ --recursive

Restore

restic restore latest --target /srv
pg_restore -d app --clean --if-exists
pg_verifybackup /bk/base
velero restore create --from-backup daily
mysql app_restore < app.sql

Failover

pg_ctl promote -D /data/pg
kubectl delete pod -l app=api
kubectl drain node-1 --ignore-daemonsets
systemctl restart postgresql@16-main
tc qdisc add dev eth0 root netem loss 20%

Verify

curl -sS -o /dev/null -w '%{http_code}' $URL
psql -c 'select pg_is_in_recovery()'
kubectl get pods -n prod -o wide
pg_amcheck -d app --heapallindexed
kubectl top pods -n prod

In one line: A plan is proven by a command, not a slide. Run one of these against a copy before you trust the plan.

Time a restore:

time restic restore latest --target /srv

Explained

Start with backup. List the snapshots, verify a subset of the data, check the base backup and confirm the offsite copy exists. A backup you cannot list is a backup you cannot restore.

Then restore. Bring the latest snapshot back into a clean target, restore the database dump, verify the base backup and create a restore from the backup object. Restoring to the same production host is not a test.

Then failover and faults. Promote the standby, delete a pod to watch the scheduler reschedule, drain a node, restart the database unit and inject packet loss. These are the drills that show whether the runbook matches the cluster.

Then verify. Check the health endpoint and the status code, confirm the database is still in recovery, watch the pods and their resource use, and run an index check on the restored data. A restore that nobody queried is a file copy.

The honest caveat: every one of these commands is safe only in the right environment. A promoted primary or a drained node in production is an incident, not a drill. Read the runbook, use a copy, and keep an abort switch.

Your turn: Which command would prove the most about your plan tomorrow?

More notes: Backup & recovery

Open in the notes app: search, filters, copy This note on GitHub