Sub topic 16
Testing restores and setting RPO and RTO
This chapter assumes you can take an etcd snapshot with etcdctl, restore it with etcdutl, and create Velero backups and restores. It also assumes you are comfortable with kubectl and SSH access to a node. A backup you have never restored is only a guess. Here you will turn the earlier steps into a repeatable restore test and use it to set recovery targets.
Two numbers that define recovery
Two terms set the goals for your backup design:
- Recovery point objective (RPO) is the most data loss you accept, measured in time. If backups run every 24 hours, your worst-case RPO is about 24 hours.
- Recovery time objective (RTO) is the longest outage you accept, measured from the failure to a working service.
The schedule you choose sets RPO. The steps you must run, and how fast they run, set RTO. You cannot read RTO off a configuration file. You have to measure it.
| Setting | What it controls | Example from this tutorial |
|---|---|---|
| Schedule interval | RPO | `velero schedule create shop-daily` runs at 02:00 daily, so RPO is about 24 hours |
| TTL | How far back you can recover | `--ttl 168h0m0s` keeps seven days of backups |
| Restore procedure | RTO | Time to install, restore, and verify |
What a restore test proves
A good test checks four things:
- The backup file exists and is readable.
- The restore completes without errors.
- The workloads start and pass health checks.
- The data is correct, not merely present.
Run Velero tests in a separate namespace or a scratch cluster. This keeps the live namespace untouched.
START=$(date +%s)
velero restore create --from-backup shop-backup \
--namespace-mappings shop:shop-restored \
--wait
kubectl -n shop-restored rollout status deployment --timeout=300s
kubectl -n shop-restored get pods,pvc
END=$(date +%s)
echo "Restore took $((END - START)) seconds"The --wait flag makes the command block until the restore finishes. The script prints the elapsed time, which is one measured input to your RTO. After the pods are ready, query the application, for example by counting rows in a database, and compare with the source.
Then check for problems that a "Completed" status can hide:
velero restore describe <restore-name> --details
velero restore logs <restore-name>Look at the warnings and errors sections. A restore can finish as PartiallyFailed or with warnings about resources that were skipped.
For etcd, test on a separate node or a throwaway cluster. Run etcdutl snapshot status first, then restore into a new data directory, as in the earlier chapter. Never practice by overwriting the data directory of your production control plane.
Measuring a full recovery
Your real RTO includes more than the restore command. Time each stage during a drill.
Because the diagram fence must name its type, here it is in the required form:
Add the time for each box. Detection and decision time are often the largest, and no tool shortens them. Alerting and a written runbook do.
Common errors
- Testing only the backup job. A green backup says nothing about the restore.
- Stale credentials. The test fails because the object storage secret expired. Better to find that in a drill.
- Forgotten dependencies. Restored pods need the same storage classes, images, and secrets that existed before.
- Untested data. Pods run, but the volume is empty because the volume backup was never enabled.
Exercise
Your Velero schedule runs every day at 02:00. A drill shows a restore takes 40 minutes, and the business requires losing no more than 4 hours of data. Which target is met, and what would you change?
Show answer
The measured restore time is a valid input for RTO, but the daily schedule gives an RPO of about 24 hours, which fails the 4-hour requirement. Change the cron expression to run at least every 4 hours, for example "0 /4 ", and set the TTL to keep a useful number of backups. Then rerun the drill.