diff --git a/postgresql/cutover/cutover.sh b/postgresql/cutover/cutover.sh index 0573072..f631cf6 100644 --- a/postgresql/cutover/cutover.sh +++ b/postgresql/cutover/cutover.sh @@ -176,6 +176,24 @@ # for the exact detection logic, the prompt itself, and the # AUTO_CLEANUP=yes escape hatch for unattended re-runs where the operator # has already decided cleanup is always wanted. +# +# 2026 run #6 (addition, no new run yet) — SESSION LOGGING added. Every +# prior investigation into a failed run depended entirely on someone +# having a live terminal open and scrolled back far enough, or on the +# operator's own memory. This is fragile, especially for the one +# genuinely dangerous scenario every phase above is built to avoid ever +# reaching manually: rollback.sh itself failing partway (see +# trigger_rollback() below — this is the one case RUNBOOK.md section 4 +# says requires manual intervention). Without a persisted transcript, +# investigating THAT scenario after the fact means reconstructing what +# happened from partial memory of a scrollback buffer that may already be +# gone. FIXED: this script now writes its ENTIRE stdout/stderr transcript +# (all 11 phases, plus Pre-Phase-0 and Phase 0's preflight.sh output, plus +# any triggered rollback.sh output) to a single timestamped file in +# BACKUP_DIR — the SAME directory the pg_dumpall backup itself lands in, +# so the backup and the transcript of the run that produced/needed it are +# always sitting right next to each other. See "SESSION LOGGING" comment +# below for implementation detail. See ADR-0001 note, Session Update 9. set -uo pipefail # NOTE: deliberately not -e — every phase below checks # its own command's exit status explicitly so we can @@ -192,6 +210,41 @@ NETWORK_NAME="postgresql_db-backend" PATRONI_SCOPE="postgres-ha" BACKUP_DIR="/volume1/SMB-docker/backup" +# ── SESSION LOGGING (added — see ADR-0001 note, Session Update 9) ──────── +# Persists this run's ENTIRE multi-phase stdout/stderr transcript to a +# single timestamped file in BACKUP_DIR — the SAME location preflight.sh +# writes the pg_dumpall backup to, per explicit operator request: the +# backup and the transcript of the run that needed it always end up +# sitting right next to each other. CUTOVER_SESSION_LOG is exported so +# preflight.sh and rollback.sh (both invoked below as plain +# `bash