backup-patternslisted
Install: claude install-skill ku5ic/dotfiles
# Backup Patterns
## When to load this skill
- User asks about backups, data retention, or disaster recovery
- Project uses PostgreSQL and needs a dump strategy
- User asks about rsync, restic, pg_dump, or pg_restore
- User is setting up a cron job for automated backups
## When not to load this skill
- Database replication or high-availability (separate from backup)
- Cloud provider snapshot configuration (AWS EBS, GCP PD)
---
## The 3-2-1 rule
Keep **3** copies of data, on **2** different storage media, with **1** copy offsite.
| Copy | Example |
| -------------- | ----------------------------------------------------- |
| Primary | Application data on the server |
| Local backup | Second disk, attached NAS |
| Offsite backup | Object storage (S3, Backblaze B2), restic remote repo |
A backup that lives only on the same server as the data is not a backup.
---
## PostgreSQL backups
### pg_dump (single database)
The custom format (`-F c`) is the most versatile: smaller than plain SQL, supports parallel restore, and supports selective restore.
```bash
pg_dump -F c -f /backups/mydb_$(date +%Y%m%d).dump mydb
```
Restore:
```bash
pg_restore -d mydb /backups/mydb_20260502.dump
```
Overwrite an existing database (drops objects before recreating):
```bash
pg_restore -d mydb --clean /backups/mydb_20260502.dump
```
### Flags reference
| Flag