Skip to main content

Runbook: Database Backup

Overview

  • What: Create manual PostgreSQL backup
  • When: Before migrations, major changes, or on-demand
  • Duration: 2-5 minutes

Prerequisites

  • SSH access to odin
  • Docker access

Procedure

Step 1: Create Backup Directory

mkdir -p ~/ravenhelm/backups

Step 2: Run Backup

Single Database

docker exec postgres pg_dump -U ravenhelm -d ravenmaskos | \
gzip > ~/ravenhelm/backups/ravenmaskos_$(date +%Y%m%d_%H%M%S).sql.gz

All Databases

docker exec postgres pg_dumpall -U ravenhelm | \
gzip > ~/ravenhelm/backups/postgres_all_$(date +%Y%m%d_%H%M%S).sql.gz

Step 3: Verify Backup

# Check file size
ls -lh ~/ravenhelm/backups/*.sql.gz | tail -1

# Test integrity
gunzip -t ~/ravenhelm/backups/<backup-file>.sql.gz

Verification

# List recent backups
ls -lt ~/ravenhelm/backups/*.sql.gz | head -5

Cleanup

Remove old manual backups:

find ~/ravenhelm/backups -name "*.sql.gz" -mtime +30 -delete