Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions .github/workflows/db-backup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,23 @@ jobs:
. /etc/os-release
echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt ${VERSION_CODENAME}-pgdg main" \
| sudo tee /etc/apt/sources.list.d/pgdg.list >/dev/null
sudo apt-get update -qq
sudo apt-get install -y -qq postgresql-client-17
pg_dump --version
sudo apt-get update
sudo apt-get install -y postgresql-client-17

# The PGDG package installs to /usr/lib/postgresql/17/bin/. The
# runner image pre-ships postgresql-client-16, so /usr/bin/pg_dump
# (a pg_wrapper symlink) may still route to v16 unless we put the
# versioned bin dir on PATH first. Append it to $GITHUB_PATH so
# subsequent steps see the v17 binary.
echo "/usr/lib/postgresql/17/bin" >> "$GITHUB_PATH"

# Hard-assert v17 is what we'll actually invoke from now on.
/usr/lib/postgresql/17/bin/pg_dump --version
PG_MAJOR=$(/usr/lib/postgresql/17/bin/pg_dump --version | awk '{print $3}' | cut -d. -f1)
if [ "${PG_MAJOR}" != "17" ]; then
echo "::error::Expected pg_dump 17, got ${PG_MAJOR}"
exit 1
fi

- name: Run pg_dump
env:
Expand All @@ -54,7 +68,9 @@ jobs:
STAMP=$(date -u +"%Y-%m-%dT%H-%M-%SZ")
FILE="out/fcf-${STAMP}.sql.gz"
echo "Dumping public schema to ${FILE}"
pg_dump \
# Invoke the v17 binary by absolute path — defense in depth in case
# something downstream resets PATH and a stray v16 wrapper sneaks in.
/usr/lib/postgresql/17/bin/pg_dump \
--schema=public \
--no-owner \
--no-privileges \
Expand Down
3 changes: 3 additions & 0 deletions docs/backup-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ If you ever need a *full* logical backup including the auth schema, run `pg_dump
**Workflow fails at "Install PostgreSQL 17 client"**
The PGDG repo URL or signing key changed. Update the install block from https://www.postgresql.org/download/linux/ubuntu/.

**`pg_dump: error: aborting because of server version mismatch`**
Supabase upgraded to a Postgres major newer than the workflow's pinned client. The runner image ships `postgresql-client-16` by default, and `/usr/bin/pg_dump` is a `pg_wrapper` symlink that can keep routing to v16 even after PGDG installs v17 — which is why the workflow now invokes `/usr/lib/postgresql/17/bin/pg_dump` by absolute path and asserts the major version before dumping. If Supabase moves to Postgres 18, bump every occurrence of `17` in `.github/workflows/db-backup.yml` to `18`.

**`pg_dump: error: connection to server … failed`**
- Confirm the host is the **session pooler** (`aws-0-<region>.pooler.supabase.com:5432`), not the direct host (`db.<ref>.supabase.co:5432`). The direct host is IPv6-only on Free tier and GitHub runners are IPv4 — the connection will silently hang and time out.
- Confirm the port is **5432** (session), not **6543** (transaction). `pg_dump` doesn't work over the transaction pooler.
Expand Down