Postgres down?
When Postgres will not start, SQL is gone. pgbx still works.
pgbx diagnosepgbx diagnose --log /var/log/postgresql/postgresql-16-main.log --pgdata /var/lib/postgresql/16/main --jsondocker logs db 2>&1 > /tmp/pg.log && pgbx diagnose --log /tmp/pg.logIt reads (each optional): postmaster.pid and liveness, pg_ctl status, the newest server log,
journalctl -u postgresql*, --log FILE, the kernel log (OOM kills), disk usage of the data dir, pg_wal,
replication slots holding WAL, pgsql_tmp, the log dir, and the data dir owner/mode.
Probable causes: oom_kill, disk_full, wal_backlog, stale_pid, crash, corruption, permissions,
config_error, too_many_connections, unknown.
{"ok": true, "command": "diagnose", "safety": "readonly", "postgres": "down", "probable_cause": "disk_full", "evidence": [{"source": "...", "line": "..."}], "steps": [{"tier": "destructive", "why": "...", "command": "...", "needs_human_approval": true}], "facts": {}}- pgbx never runs a step. Destructive steps are marked for human approval.
pg_wal,base,globalandpg_xactare never offered for deletion.pgbx doctorruns the diagnosis automatically when Postgres is unreachable (diagnosisin its JSON).- Lost the server for good?
pgbx db-restore --from-s3restores each database onto a new one; see Disaster recovery.