Overview
Designs a complete backup and disaster recovery (DR) strategy including RPO/RTO definitions, backup methods for databases (pg_dump, WAL archiving, snapshots), file/object storage backups, S3 lifecycle rules, encryption at rest and in transit, automated restore testing, retention schedules following the 3-2-1 rule, and an incident runbook template for restore scenarios.
When to Use This Skill
- Setting up production data protection for the first time.
- Auditing or improving existing backup processes.
- Preparing for compliance or business continuity requirements.
Prerequisites
- Production databases and file storage identified.
- Access to S3 or equivalent object storage with versioning/lifecycle.
- Ability to run backup jobs (cron, Kubernetes CronJob, cloud scheduled tasks).
Steps
Define RPO and RTO for each data tier:
- RPO (Recovery Point Objective): How much data loss is acceptable?
- RTO (Recovery Time Objective): How long to restore service?
Database backup methods (choose per DB):
- Full logical (pg_dump, mysqldump) — good for small DBs or point-in-time restore needs.
- Continuous WAL / PITR (PostgreSQL pg_basebackup + archiving, MySQL binlog).
- Storage snapshots (EBS, GCP PD, Azure Disk) — fast for large DBs.
- Managed service backups (RDS automated, Cloud SQL, etc.).
File / object storage:
- S3 versioning + cross-region replication.
- Lifecycle policies: transition to IA/Glacier after 30/90 days, expire after retention period.
Encryption & security:
- Encrypt backups at rest (KMS or S3 SSE).
- Encrypt in transit (TLS).
- Least-privilege IAM for backup jobs.
Retention (3-2-1 rule):
- 3 copies of data.
- 2 different media/types.
- 1 offsite / in different region/account.
Automated restore testing:
- Schedule monthly/quarterly restore to a staging environment.
- Script the restore and verify data integrity (row counts, checksums).
- Document the runbook.
Output:
- Backup architecture diagram (text or Mermaid).
- Cron / CronJob / cloud schedule definitions.
- Restore scripts (example for Postgres from S3).
- Retention policy.
- Incident runbook template for "data loss event".
Examples
A complete strategy for a PostgreSQL + S3 user uploads system is included, with pg_dump + WAL shipping to S3, lifecycle rules, a restore script, and a quarterly restore test CronJob.
Edge Cases & Error Handling
- Partial corruption: PITR allows restoring to just before the corruption.
- Ransomware / malicious delete: Immutable backups (S3 Object Lock, WORM) or cross-account backups.
- Cost control: Lifecycle policies + infrequent access / Glacier.
Verification
- Backups are running on schedule and landing in the correct location.
- A test restore completes within the target RTO and data is verified correct.
- Delete a file or row in prod and confirm it can be recovered from backup.
- Check that old backups are being expired per policy.
- Success: RPO and RTO targets are met, restores are tested regularly, and data is protected against common failure modes including human error and ransomware.
References
1---2name: backup-strategy3description: Designs and implements a backup and disaster recovery strategy for databases and file storage. Use when setting up backups for production data.4license: Apache-2.05---67## Overview89Designs a complete backup and disaster recovery (DR) strategy including RPO/RTO definitions, backup methods for databases (pg_dump, WAL archiving, snapshots), file/object storage backups, S3 lifecycle rules, encryption at rest and in transit, automated restore testing, retention schedules following the 3-2-1 rule, and an incident runbook template for restore scenarios.1011## When to Use This Skill1213- Setting up production data protection for the first time.14- Auditing or improving existing backup processes.15- Preparing for compliance or business continuity requirements.1617## Prerequisites1819- Production databases and file storage identified.20- Access to S3 or equivalent object storage with versioning/lifecycle.21- Ability to run backup jobs (cron, Kubernetes CronJob, cloud scheduled tasks).2223## Steps24251. **Define RPO and RTO** for each data tier:26 - RPO (Recovery Point Objective): How much data loss is acceptable?27 - RTO (Recovery Time Objective): How long to restore service?28292. **Database backup methods** (choose per DB):30 - Full logical (pg_dump, mysqldump) — good for small DBs or point-in-time restore needs.31 - Continuous WAL / PITR (PostgreSQL pg_basebackup + archiving, MySQL binlog).32 - Storage snapshots (EBS, GCP PD, Azure Disk) — fast for large DBs.33 - Managed service backups (RDS automated, Cloud SQL, etc.).34353. **File / object storage**:36 - S3 versioning + cross-region replication.37 - Lifecycle policies: transition to IA/Glacier after 30/90 days, expire after retention period.38394. **Encryption & security**:40 - Encrypt backups at rest (KMS or S3 SSE).41 - Encrypt in transit (TLS).42 - Least-privilege IAM for backup jobs.43445. **Retention (3-2-1 rule)**:45 - 3 copies of data.46 - 2 different media/types.47 - 1 offsite / in different region/account.48496. **Automated restore testing**:50 - Schedule monthly/quarterly restore to a staging environment.51 - Script the restore and verify data integrity (row counts, checksums).52 - Document the runbook.53547. **Output**:55 - Backup architecture diagram (text or Mermaid).56 - Cron / CronJob / cloud schedule definitions.57 - Restore scripts (example for Postgres from S3).58 - Retention policy.59 - Incident runbook template for "data loss event".6061## Examples6263A complete strategy for a PostgreSQL + S3 user uploads system is included, with pg_dump + WAL shipping to S3, lifecycle rules, a restore script, and a quarterly restore test CronJob.6465## Edge Cases & Error Handling6667- **Partial corruption**: PITR allows restoring to just before the corruption.68- **Ransomware / malicious delete**: Immutable backups (S3 Object Lock, WORM) or cross-account backups.69- **Cost control**: Lifecycle policies + infrequent access / Glacier.7071## Verification72731. Backups are running on schedule and landing in the correct location.742. A test restore completes within the target RTO and data is verified correct.753. Delete a file or row in prod and confirm it can be recovered from backup.764. Check that old backups are being expired per policy.775. Success: RPO and RTO targets are met, restores are tested regularly, and data is protected against common failure modes including human error and ransomware.7879## References8081- [3-2-1 Backup Rule](https://www.backblaze.com/blog/the-3-2-1-backup-rule/)82- [PostgreSQL Backup & PITR](https://www.postgresql.org/docs/current/continuous-archiving.html)83- [AWS S3 Lifecycle](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html)84- [S3 Object Lock](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock.html)