Designing for Disaster Recovery: RTO, RPO, and Resilience
Learn how to design for disaster recovery by mastering RTO and RPO. Build a robust backup strategy and test your systems for worst-case scenarios.

Previously in this course, we discussed production readiness checklists to ensure our systems are stable under normal operations. Now, we must address the "what if" scenario: when the worst happens and your infrastructure or data is compromised, how do you recover?
Disaster recovery (DR) is the discipline of planning for catastrophic events—data center outages, regional cloud failures, or massive data corruption—that standard high-availability patterns cannot handle.
Defining Your Recovery Targets: RTO and RPO
Before writing a single line of backup code, you must quantify your requirements using two industry-standard metrics: Recovery Time Objective (RTO) and Recovery Point Objective (RPO). These aren't just technical metrics; they are business constraints.
- Recovery Time Objective (RTO): The maximum tolerable duration of downtime. If your site goes down at 10:00 AM, and your RTO is 1 hour, your system must be back online by 11:00 AM.
- Recovery Point Objective (RPO): The maximum tolerable amount of data loss, measured in time. If your RPO is 5 minutes, you must ensure that in a disaster, you lose no more than 5 minutes of data.
| Metric | Focus | Question to Ask |
|---|---|---|
| RTO | Time | How fast must we be back up? |
| RPO | Data | How much data can we afford to lose? |
If you aim for an RTO of zero and an RPO of zero, you are looking at active-active multi-region replication, which is expensive and complex. Most beginners should start by defining realistic thresholds (e.g., RTO of 4 hours, RPO of 1 hour) and building toward those.
Creating a Concrete Backup Strategy

A backup strategy is useless if it exists only in your head. You need a documented, automated process. When designing for failure, you must treat your backups as a critical system component.
The 3-2-1 Rule
A robust strategy follows the 3-2-1 rule:
- Keep 3 copies of your data.
- Store them on 2 different types of media (e.g., disk and cloud object storage).
- Keep 1 copy off-site (e.g., a different cloud region).
For our running project, let’s assume we are using a PostgreSQL database. A naive backup is just a nightly pg_dump. A professional approach involves continuous archiving using Write-Ahead Logs (WAL).
Worked Example: Automated Backup Logic
We can use a simple script to trigger a snapshot and verify its existence in an S3 bucket.
Bash#!/bin/bash # Simple backup script for PostgreSQL TIMESTAMP=$(date +"%Y-%m-%dT%H:%M:%S") DB_NAME="production_db" BACKUP_FILE="/tmp/backup-$TIMESTAMP style="color:#569CD6">.sql" # 1. Perform the dump pg_dump $DB_NAME > $BACKUP_FILE # 2. Upload to off-site storage (e.g., AWS S3) aws s3 cp $BACKUP_FILE s3://my-org-backups/db-backups/ # 3. Verify upload success if [ $? -eq 0 ]; then echo "Backup successful: $TIMESTAMP" rm $BACKUP_FILE else echo "Backup failed!" | mail -s "DR ALERT" admin@example.com fi
Testing Your Disaster Recovery Scenario
Most systems fail during a disaster not because they lacked backups, but because the restoration process was never tested. A backup is just a file until you successfully restore it.
To test your strategy, perform a Game Day:
- Isolate the environment: Create a staging environment that mirrors production.
- Simulate corruption: Manually drop a table or delete a critical set of data.
- Execute the recovery: Follow your documented steps to restore from your latest backup.
- Measure: Did you meet your RTO? Did you lose more data than your RPO allowed?
If you find the process took 6 hours, but your RTO was 1 hour, you have identified a bottleneck. You might need to move from full dumps to incremental backups or utilize automated tools like Kubernetes backup strategies using Velero.
Common Pitfalls

- Ignoring the "Restore" Test: Assuming that because the "Backup" job returns a green status, the data is valid. Always test the restore.
- Hard-coded credentials: Never put database credentials in your backup scripts. Use secret managers or environment-based IAM roles.
- Single-Region Dependency: If your backup is in the same cloud region as your server, a regional power failure takes out both. Always replicate backups to a separate region.
FAQ
Q: Does my database replication (master-slave) count as a backup?
A: No. Replication is for high availability. If you accidentally run DROP TABLE, that command replicates to the slave instantly. Backups provide a point-in-time recovery to undo human errors.
Q: How often should I test my DR plan? A: At a minimum, every quarter. As your system architecture evolves, your recovery process will likely break.
Recap

Disaster recovery is about defining your business constraints (RTO and RPO) and ensuring your infrastructure can meet them. Always follow the 3-2-1 rule for data storage, and treat your restore process as an exercise that must be practiced regularly. Just as we use rollback strategies to handle deployment failures, we use DR to handle infrastructure failures.
Up next: We will discuss how to perform a blameless post-mortem after an incident occurs.
Work with me

Custom Email & File Storage System on Cloudflare (Google Workspace Alternative)
Your own private email + file storage suite on your domain — unlimited mailboxes, no per-seat fees. A self-owned Google Workspace alternative for a flat ~$5/month.

Next.js Website & Landing Page Development
A blazing-fast, SEO-optimized website or landing page in Next.js — the kind that loads instantly and ranks. Design-to-code, done right.


