Skip to main content

Runbook: Database Restore

Purpose

Restore PostgreSQL data from a backup file after data loss or corruption.

Prerequisites

  • SSH access to odin
  • Backup file available in ~/ravenhelm/backups/
  • Maintenance window for dependent services

Procedure

Step 1: Stop dependent services

ssh ravenhelm@100.115.101.81 "docker stop norns-agent"

Step 2: Identify the backup

ssh ravenhelm@100.115.101.81 "ls -lh ~/ravenhelm/backups | grep postgres"

Step 3: Restore the database

For a compressed SQL backup:

ssh ravenhelm@100.115.101.81 "gunzip -c ~/ravenhelm/backups/backup.sql.gz | docker exec -i postgres psql -U ravenhelm -d ravenmaskos"

For a custom format dump:

ssh ravenhelm@100.115.101.81 "docker exec -i postgres pg_restore -U ravenhelm -d ravenmaskos < ~/ravenhelm/backups/backup.dump"

Step 4: Restart services

ssh ravenhelm@100.115.101.81 "docker start norns-agent"

Verification

ssh ravenhelm@100.115.101.81 "docker exec -it postgres psql -U ravenhelm -d ravenmaskos -c '\\dt'"

Rollback

If the restore fails, retry with a different backup file. Document the incident before reattempting.