Skip to content

feat: additional config for pgbackrest#2099

Open
Crispy1975 wants to merge 12 commits intodevelopfrom
pjc/indata-403-admin-agent-pgbackrest
Open

feat: additional config for pgbackrest#2099
Crispy1975 wants to merge 12 commits intodevelopfrom
pjc/indata-403-admin-agent-pgbackrest

Conversation

@Crispy1975
Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Additional config for pgBackRest backups and restores. Details further in: https://linear.app/supabase/issue/INDATA-403/admin-agent-add-new-command-to-control-pgbackrest

@Crispy1975 Crispy1975 self-assigned this Mar 30, 2026
@Crispy1975 Crispy1975 force-pushed the pjc/indata-403-admin-agent-pgbackrest branch from 8f44ad4 to 2370c92 Compare March 31, 2026 16:50
@Crispy1975 Crispy1975 force-pushed the pjc/indata-403-admin-agent-pgbackrest branch from 2370c92 to d1b6678 Compare April 2, 2026 13:19
@Crispy1975 Crispy1975 requested a review from hunleyd April 3, 2026 15:55
Copy link
Copy Markdown
Contributor

@hunleyd hunleyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Crispy1975 Crispy1975 marked this pull request as ready for review April 3, 2026 16:59
@Crispy1975 Crispy1975 requested review from a team as code owners April 3, 2026 16:59
Crispy1975 and others added 8 commits April 9, 2026 13:19
- pgdata-signal: add remove-pid action to remove stale postmaster.pid
  via the constrained wrapper rather than a broad sudo rm entry,
  keeping the sudoers scope limited to this script
- pgdata-chown: simplify case; use group=postgres consistently for both
  ownership targets (pgbackrest:postgres and postgres:postgres)
- pgdata-signal: consolidate recovery/standby case into single pattern
- pgdata-signal: deploy at mode 0755 so postgres can execute via sudo -u
- setup-pgbackrest.yml: combine dir creation into single task with dict
  loop; conf.d gets 02770 setgid, others get default 0770
- setup-pgbackrest.yml: sort logrotate task keys alphabetically
Three gaps found by cross-referencing SAA commands against Ansible:

1. adminapi.sudoers.conf: add two entries so adminapi can call the
   pgbackrest binary via the wrapper.
   - NewRunner() path: wrapper calls sudo -u pgbackrest <real binary>,
     requires adminapi -> pgbackrest NOPASSWD for the real binary path.
   - NewRunnerAs("pgbackrest") path: SAA does sudo -n -u pgbackrest
     /usr/bin/pgbackrest, requires adminapi -> pgbackrest NOPASSWD for
     the wrapper path.

2. setup-pgbackrest.yml: add pgbackrest -> pgbackrest sudoers entry for
   the real binary. When NewRunnerAs runs the wrapper as the pgbackrest
   user, the wrapper still calls sudo -u pgbackrest internally; without
   this entry that inner sudo fails.

3. setup-pgbackrest.yml: pre-create the three SAA log files
   (saa-pgb.log, wal-push.log, wal-fetch.log) as pgbackrest:postgres
   0660. SAA opens them with O_APPEND|O_WRONLY (no O_CREATE) — a missing
   file causes enable to fail immediately before any pgBackRest work.
   modification_time/access_time: preserve means the task is idempotent.
Co-authored-by: Tom Ashley <tom.ashley@gmail.com>
Co-authored-by: Tom Ashley <tom.ashley@gmail.com>
Co-authored-by: Tom Ashley <tom.ashley@gmail.com>
Replace trust with peer map=saa_map for the supabase_admin pg_hba rule.
Add saa_map entries in pg_ident.conf mapping adminapi and root OS users
to the supabase_admin PG user, as required by supabase-admin-agent.
pgdata-signal is called via sudo as postgres (other user), so it must
be world-executable. 0700 would prevent postgres from running it.
@Crispy1975 Crispy1975 force-pushed the pjc/indata-403-admin-agent-pgbackrest branch from b1a04b4 to 7425331 Compare April 9, 2026 12:19
peer map=saa_map cannot be cleanly implemented in pg_hba.conf.j2 while
the Dockerfiles copy it raw — pg_hba include_if_exists (PG 16+) is
needed to separate Docker from production, and that work is in progress
on a separate branch.

Trust is appropriate for this local Unix-socket-only connection; the
security boundary is OS-level access to the machine. Revisit once the
include directive infrastructure lands.
Clarify the intent and rationale behind the less-obvious changes:
- adminapi.sudoers.conf: explain the two pgbackrest sudo chains
  (NewRunner vs NewRunnerAs) and the wrapper/real-binary split
- supabase-admin-agent.yml: explain why pgdata-chown is 0700 and
  pgdata-signal is 0755
- setup-pgbackrest.yml: explain the pgbackrest self-sudo entry,
  why conf.d needs setgid (02770), and why SAA log files must be
  pre-created before the agent runs
- pgbackrest.conf: explain expire-auto change and why the [supabase]
  stanza was removed (SAA owns it via conf.d to avoid error [031])
- Move from pgbackrest_config/ to logrotate_config/ to match the
  existing pattern for all other logrotate configs in the repo
- Deploy via the finalize-ami.yml loop rather than setup-pgbackrest.yml
- Add size 50M cap to prevent logs growing unbounded between daily
  rotations during large backup/restore operations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants