$npx -y skills add BagelHole/DevOps-Security-Agent-Skills --skill disaster-recoveryImplement disaster recovery strategies and runbooks. Configure RPO/RTO targets and failover procedures. Use when planning for business continuity.
| 1 | # Disaster Recovery |
| 2 | |
| 3 | Implement disaster recovery strategies including RTO/RPO planning, AWS cross-region failover patterns, DR testing procedures, and automated failover scripts. |
| 4 | |
| 5 | ## When to Use |
| 6 | |
| 7 | - Defining RTO and RPO targets for critical systems |
| 8 | - Designing multi-region or multi-cloud disaster recovery architectures |
| 9 | - Implementing automated failover and failback procedures |
| 10 | - Conducting DR tests (tabletop, component, full failover) |
| 11 | - Meeting compliance requirements for contingency planning (SOC 2, HIPAA, FedRAMP, ISO 27001) |
| 12 | |
| 13 | ## RTO/RPO Planning |
| 14 | |
| 15 | ```yaml |
| 16 | recovery_metrics: |
| 17 | RTO: |
| 18 | definition: "Recovery Time Objective - maximum acceptable downtime" |
| 19 | measurement: "From incident declaration to service restoration" |
| 20 | factors: |
| 21 | - Failover automation maturity |
| 22 | - Data replication lag |
| 23 | - DNS propagation time |
| 24 | - Application warm-up time |
| 25 | - Verification procedures |
| 26 | |
| 27 | RPO: |
| 28 | definition: "Recovery Point Objective - maximum acceptable data loss" |
| 29 | measurement: "Time gap between last good backup and the incident" |
| 30 | factors: |
| 31 | - Backup frequency |
| 32 | - Replication method (sync vs. async) |
| 33 | - Transaction log shipping interval |
| 34 | - Cross-region replication lag |
| 35 | |
| 36 | service_tier_targets: |
| 37 | tier_1_critical: |
| 38 | examples: "Authentication, payment processing, core API" |
| 39 | rto: "< 15 minutes" |
| 40 | rpo: "< 1 minute (near-zero)" |
| 41 | strategy: "Multi-site active-active or warm standby" |
| 42 | replication: "Synchronous or near-synchronous" |
| 43 | testing: "Quarterly failover test" |
| 44 | |
| 45 | tier_2_essential: |
| 46 | examples: "Customer dashboards, reporting, notifications" |
| 47 | rto: "< 1 hour" |
| 48 | rpo: "< 15 minutes" |
| 49 | strategy: "Warm standby or pilot light" |
| 50 | replication: "Asynchronous with short interval" |
| 51 | testing: "Semi-annual failover test" |
| 52 | |
| 53 | tier_3_standard: |
| 54 | examples: "Internal tools, analytics, batch processing" |
| 55 | rto: "< 4 hours" |
| 56 | rpo: "< 1 hour" |
| 57 | strategy: "Pilot light or backup and restore" |
| 58 | replication: "Periodic snapshots" |
| 59 | testing: "Annual failover test" |
| 60 | |
| 61 | tier_4_non_essential: |
| 62 | examples: "Development environments, documentation sites" |
| 63 | rto: "< 24 hours" |
| 64 | rpo: "< 24 hours" |
| 65 | strategy: "Backup and restore" |
| 66 | replication: "Daily backups" |
| 67 | testing: "Annual backup restore verification" |
| 68 | ``` |
| 69 | |
| 70 | ## DR Strategies Comparison |
| 71 | |
| 72 | ```yaml |
| 73 | strategies: |
| 74 | backup_and_restore: |
| 75 | rto: "Hours" |
| 76 | rpo: "Hours (depends on backup frequency)" |
| 77 | cost: "$" |
| 78 | description: "Regular backups stored in DR region. Restore from backup when needed." |
| 79 | aws_services: |
| 80 | - "S3 cross-region replication for backups" |
| 81 | - "RDS automated snapshots copied to DR region" |
| 82 | - "AMI copies in DR region" |
| 83 | - "Terraform/CloudFormation for infrastructure rebuild" |
| 84 | pros: "Lowest cost, simplest to maintain" |
| 85 | cons: "Longest recovery time, highest data loss potential" |
| 86 | |
| 87 | pilot_light: |
| 88 | rto: "Minutes to hours" |
| 89 | rpo: "Minutes" |
| 90 | cost: "$$" |
| 91 | description: "Core infrastructure running in DR region (databases replicated). Scale up compute on failover." |
| 92 | aws_services: |
| 93 | - "RDS cross-region read replica (always running)" |
| 94 | - "S3 cross-region replication" |
| 95 | - "AMIs pre-built in DR region" |
| 96 | - "Auto Scaling groups at zero/minimal capacity" |
| 97 | pros: "Fast database recovery, moderate cost" |
| 98 | cons: "Compute scale-up adds to recovery time" |
| 99 | |
| 100 | warm_standby: |
| 101 | rto: "Minutes" |
| 102 | rpo: "Seconds to minutes" |
| 103 | cost: "$$$" |
| 104 | description: "Scaled-down but functional environment in DR region. Scale up on failover." |
| 105 | aws_services: |
| 106 | - "RDS cross-region read replica" |
| 107 | - "ECS/EKS running at reduced capacity" |
| 108 | - "Route53 health checks for automated DNS failover" |
| 109 | - "Global Accelerator for traffic management" |
| 110 | pros: "Fast failover, reduced risk" |
| 111 | cons: "Higher baseline cost for idle resources" |
| 112 | |
| 113 | multi_site_active: |
| 114 | rto: "Near-zero" |
| 115 | rpo: "Near-zero" |
| 116 | cost: "$$$$" |
| 117 | description: "Active-active across regions. Traffic served from both regions simultaneously." |
| 118 | aws_services: |
| 119 | - "DynamoDB Global Tables or Aurora Global Database" |
| 120 | - "Route53 latency/weighted routing" |
| 121 | - "CloudFront with multi-origin" |
| 122 | - "Global Accelerator" |
| 123 | - "ECS/EKS in both regions" |
| 124 | pros: "Minimal downtime and data loss" |
| 125 | cons: "Highest cost, most complex to operate" |
| 126 | ``` |
| 127 | |
| 128 | ## AWS Cross-Region DR Implementation |
| 129 | |
| 130 | ```bash |
| 131 | # === Database Replication === |
| 132 | |
| 133 | # Create cross-region RDS read replica |
| 134 | aws rds create-db-instance-read-replica \ |
| 135 | --db-instance-identifier prod-db-dr-replica \ |
| 136 | --source-db-instance-identifier arn:aws:rds:us-east-1:123456789012:db:prod-db \ |
| 137 | --db-instance-class db.r6g.large \ |
| 138 | --region us-west-2 \ |
| 139 | --kms-key-id arn:aws:kms:us-west-2:123456789012:alias/rds-dr-k |