Skip to content

Chapter 12: Operations

12.1 Backups

  • RDS automated backups (7–35 days) + a manual snapshot before risky changes.
  • Self-hosted Postgres: daily pg_dump -Fc → gzip → S3 (bucket not public, versioning on), keep N days.
  • Test a restore monthly into a throwaway instance (R13).

12.2 Monitoring and alerts (R12)

| What | How | | ------------------ | --------------------------------------------------------------------------------------------- | --------- | ------- | | Site down | Uptime check on https://<domain>/health (external service or Route 53 health check → alarm) | | CPU high (miners!) | CloudWatch alarm: EC2 CPUUtilization > 70% for 30 min → SNS email | | Instance health | CloudWatch alarm: StatusCheckFailed | | RDS | Alarms on CPUUtilization, FreeStorageSpace, DatabaseConnections spikes | | Threats | GuardDuty findings → EventBridge → SNS email | | Auth noise | Weekly: RDS/Postgres logs grep -E "authentication failed | no pg_hba | FATAL" |

12.3 Patching

  • Unattended security upgrades on the host; monthly apt full-upgrade + reboot window.
  • Rebuild images monthly (docker compose build --pull) to pick up base-image fixes.
  • RDS: auto minor version upgrade on; plan major upgrades.

12.4 Monthly audit (30 minutes)

  • Security groups: every inbound rule still needed? any 0.0.0.0/0 besides 80/443? anything in default?
  • RDS: Public access still No? dig still private?
  • sudo ss -tlnp on each server matches Chapter 11 row 1.
  • IAM: unused users/keys removed; MFA on all humans.
  • SSH authorized_keys on each server: only current people.
  • DB roles: select rolname, rolsuper from pg_roles where rolname !~ '^(pg_|rds)': only known roles.
  • GuardDuty findings reviewed; CloudTrail trail still logging.
  • Backups present; last restore test date.
  • Certificates renewing (certbot renew --dry-run).