RDB backup scheduling, AOF log shipping to cold storage, BGSAVE + BGREWRITEAOF interaction, DEBUG RELOAD for in-memory consistency checks, and a documented recovery runbook for the three most common failure scenarios.
A-13 — Disaster Recovery, Backup, and Point-in-Time Restore
Who this module is for: Redis is holding data that matters — sessions, job queues, rate limit state, coordination locks. If the server dies, you need to recover. This module covers RDB backup scheduling, AOF log shipping, recovery runbooks for the three most common failure scenarios, and the one practice most teams skip: testing restore procedures before they need them.
The Backup Strategy Pyramid
Not all Redis data needs the same protection:
| Data Type | Recovery Strategy | RTO | RPO |
|---|---|---|---|
| Pure cache | Regenerate from DB on miss | Seconds | Any (cache is disposable) |
| Session store | Restore from RDB + accept some logouts | Minutes | Last snapshot |
| Job queue | Restore from RDB + reprocess in-flight jobs | Minutes | Last snapshot |
| Rate limit state | Restore from RDB + accept burst on restart | Minutes | Last snapshot |
| Event log / audit trail | AOF log shipping + S3 | < 30 min | < 1 minute |
RPO (Recovery Point Objective): Maximum acceptable data loss (time).
RTO (Recovery Time Objective): Maximum acceptable downtime (time to recover).
Design your persistence configuration to meet the RPO; design your restore procedure to meet the RTO.
RDB Backup Scheduling
Automated Periodic Snapshots
Add to cron:
Backup Retention Policy
Implement with S3 Lifecycle policies:
AOF Log Shipping
For near-real-time backup (RPO < 1 minute), ship the AOF file to durable storage continuously:
For Redis 7.0+ multi-part AOF (RDB base + incremental AOF files):
BGSAVE and BGREWRITEAOF Interaction
If you're shipping both RDB snapshots and AOF files as backup layers, know what happens when they overlap: Redis will not run BGSAVE and BGREWRITEAOF at the same time. If a BGREWRITEAOF is already in progress and a scheduled BGSAVE fires (or vice versa), the second one is deferred — Redis logs a message and starts it automatically once the first finishes, rather than running both fork()s concurrently. This matters for backup scheduling in two ways:
- Don't assume your RDB backup cron job and your AOF rewrite trigger are independent. If they collide, your backup script needs to poll (
INFO persistence— checkrdb_bgsave_in_progress/aof_rewrite_in_progress) rather than assuming the snapshot completed on schedule. - Both operations fork a child process, and both children hold a copy-on-write reference to the dataset. If they did somehow overlap (they don't, by design, but a naive mental model might assume otherwise), you'd risk doubling the memory overhead from copy-on-write page duplication under write load — one more reason Redis serializes them rather than running both at once.
Sign in to keep reading
The rest of this module is free — sign in with Google to unlock it and track your progress.
Sign in & RegisterDiscussion
0Join the discussion