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.05compatibility: Claude Code, Codex, Gemini CLI6metadata:7 author: ai-skills8 version: "1.0"9 category: devops10 tags: backup, disaster-recovery, rpo, rto, postgres, s3, encryption11---1213## Overview1415Designs 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.1617## When to Use This Skill1819- Setting up production data protection for the first time.20- Auditing or improving existing backup processes.21- Preparing for compliance or business continuity requirements.2223## Prerequisites2425- Production databases and file storage identified.26- Access to S3 or equivalent object storage with versioning/lifecycle.27- Ability to run backup jobs (cron, Kubernetes CronJob, cloud scheduled tasks).2829## Steps30311. **Define RPO and RTO** for each data tier:32 - RPO (Recovery Point Objective): How much data loss is acceptable?33 - RTO (Recovery Time Objective): How long to restore service?34352. **Database backup methods** (choose per DB):36 - Full logical (pg_dump, mysqldump) — good for small DBs or point-in-time restore needs.37 - Continuous WAL / PITR (PostgreSQL pg_basebackup + archiving, MySQL binlog).38 - Storage snapshots (EBS, GCP PD, Azure Disk) — fast for large DBs.39 - Managed service backups (RDS automated, Cloud SQL, etc.).40413. **File / object storage**:42 - S3 versioning + cross-region replication.43 - Lifecycle policies: transition to IA/Glacier after 30/90 days, expire after retention period.44454. **Encryption & security**:46 - Encrypt backups at rest (KMS or S3 SSE).47 - Encrypt in transit (TLS).48 - Least-privilege IAM for backup jobs.49505. **Retention (3-2-1 rule)**:51 - 3 copies of data.52 - 2 different media/types.53 - 1 offsite / in different region/account.54556. **Automated restore testing**:56 - Schedule monthly/quarterly restore to a staging environment.57 - Script the restore and verify data integrity (row counts, checksums).58 - Document the runbook.59607. **Output**:61 - Backup architecture diagram (text or Mermaid).62 - Cron / CronJob / cloud schedule definitions.63 - Restore scripts (example for Postgres from S3).64 - Retention policy.65 - Incident runbook template for "data loss event".6667## Examples6869A 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.7071## Edge Cases & Error Handling7273- **Partial corruption**: PITR allows restoring to just before the corruption.74- **Ransomware / malicious delete**: Immutable backups (S3 Object Lock, WORM) or cross-account backups.75- **Cost control**: Lifecycle policies + infrequent access / Glacier.7677## Verification78791. Backups are running on schedule and landing in the correct location.802. A test restore completes within the target RTO and data is verified correct.813. Delete a file or row in prod and confirm it can be recovered from backup.824. Check that old backups are being expired per policy.835. Success: RPO and RTO targets are met, restores are tested regularly, and data is protected against common failure modes including human error and ransomware.8485## References8687- [3-2-1 Backup Rule](https://www.backblaze.com/blog/the-3-2-1-backup-rule/)88- [PostgreSQL Backup & PITR](https://www.postgresql.org/docs/current/continuous-archiving.html)89- [AWS S3 Lifecycle](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html)90- [S3 Object Lock](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock.html)