Runbook: Database Disaster Recovery & Restore
Runbook: Database Disaster Recovery & Restore
Section titled “Runbook: Database Disaster Recovery & Restore”Trigger: Database corruption, unintended drop/truncate command, or recovery drill.
Pre-Requisites
Section titled “Pre-Requisites”- Identification of target database container or host instance.
- Verified backup archive (
.sql.gz) with SHA-256 integrity check.
Restoration Procedure (PostgreSQL Container Example)
Section titled “Restoration Procedure (PostgreSQL Container Example)”Step 1: Stop Writing Services
Section titled “Step 1: Stop Writing Services”# Example for Umami stackcd /opt/umamidocker compose stop umamiStep 2: Prepare Clean Database Target
Section titled “Step 2: Prepare Clean Database Target”# Drop and recreate schema inside database containerdocker exec -it <db_container> dropdb -U <db_user> <db_name>docker exec -it <db_container> createdb -U <db_user> <db_name>Step 3: Stream Backup to PostgreSQL
Section titled “Step 3: Stream Backup to PostgreSQL”gunzip -c /path/to/backup.sql.gz | docker exec -i <db_container> psql -U <db_user> -d <db_name>Step 4: Restart Application Stack & Verify
Section titled “Step 4: Restart Application Stack & Verify”cd /opt/umamidocker compose up -ddocker compose logs -f --tail=50