-
-
Notifications
You must be signed in to change notification settings - Fork 236
feat: additional config for pgbackrest #2099
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Crispy1975
wants to merge
12
commits into
develop
Choose a base branch
from
pjc/indata-403-admin-agent-pgbackrest
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
26c62c6
feat: additional config for pgbackrest
Crispy1975 4e94a8d
fix: address pgbackrest PR review feedback
Crispy1975 81774c7
fix: add missing pgbackrest sudoers entries and pre-create log files
Crispy1975 4552fb0
Update ansible/files/supabase_admin_agent_config/pgdata-signal
hunleyd 8efab8c
Update ansible/files/supabase_admin_agent_config/pgdata-signal
hunleyd f5d5b34
Update ansible/tasks/internal/supabase-admin-agent.yml
hunleyd 24e4bfb
fix: use peer auth with saa_map for supabase_admin local connections
Crispy1975 7425331
fix: restore pgdata-signal mode to 0755
Crispy1975 05195c5
fix: revert supabase_admin auth to trust, remove saa_map from pg_ident
Crispy1975 c01d48f
docs: add comment to supabase_admin trust rule in pg_hba.conf
Crispy1975 05b68f8
docs: add explanatory comments to pgBackRest Ansible changes
Crispy1975 d530fa7
fix: move pgbackrest logrotate config to follow repo convention
Crispy1975 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| /var/log/pgbackrest/*.log { | ||
| daily | ||
| size 50M | ||
| rotate 7 | ||
| compress | ||
| delaycompress | ||
| missingok | ||
| notifempty | ||
| create 0660 pgbackrest postgres | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #!/usr/bin/env bash | ||
| # pgdata-chown — transfers PGDATA ownership for pgBackRest restore operations. | ||
| # | ||
| # Called via sudo by supabase-admin-agent (running as adminapi). Only two | ||
| # actions are accepted, and the target path must resolve to /data/pgdata or a | ||
| # path beneath it. realpath(1) is used to expand symlinks before the check, | ||
| # which prevents directory-traversal attacks (e.g. /data/pgdata/../../etc/sudoers). | ||
| # | ||
| # Usage: pgdata-chown <to-pgbackrest|to-postgres> <path> | ||
| set -euo pipefail | ||
|
|
||
| if [[ $# -ne 2 ]]; then | ||
| echo "usage: pgdata-chown <to-pgbackrest|to-postgres> <path>" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| ACTION="$1" | ||
| TARGET="$2" | ||
|
|
||
| REAL=$(realpath "$TARGET") | ||
| if [[ "$REAL" != "/data/pgdata" && "$REAL" != /data/pgdata/* ]]; then | ||
| echo "error: '${TARGET}' resolves to '${REAL}', which is not under /data/pgdata" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| case "$ACTION" in | ||
| to-pgbackrest|to-postgres) | ||
| exec /usr/bin/chown -R "${ACTION:3}:postgres" "$REAL" | ||
| ;; | ||
| *) | ||
| echo "error: unknown action '${ACTION}'; expected to-pgbackrest or to-postgres" >&2 | ||
| exit 1 | ||
| ;; | ||
| esac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| #!/usr/bin/env bash | ||
| # pgdata-signal — creates or removes PostgreSQL signal files and stale pid files. | ||
| # Called via sudo (as postgres) by supabase-admin-agent (running as adminapi). | ||
| # | ||
| # All file paths are hardcoded to prevent path injection. No external | ||
| # path argument is accepted. | ||
| # | ||
| # Usage: pgdata-signal <create|remove> <recovery|standby> | ||
| # pgdata-signal remove-pid | ||
| set -euo pipefail | ||
|
|
||
| # Special-case: remove-pid removes the stale postmaster.pid file that would | ||
| # prevent PostgreSQL from starting after a restore. Handled as a single-arg | ||
| # command to keep the sudoers entry scoped to this script rather than allowing | ||
| # a broad "rm" entry. | ||
| if [[ $# -eq 1 && "$1" == "remove-pid" ]]; then | ||
| exec /usr/bin/rm -f "/data/pgdata/postmaster.pid" | ||
| fi | ||
|
|
||
| if [[ $# -ne 2 ]]; then | ||
| echo "usage: pgdata-signal <create|remove> <recovery|standby>" >&2 | ||
| echo " pgdata-signal remove-pid" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| ACTION="$1" | ||
| SIGNAL_TYPE="$2" | ||
|
|
||
| case "$SIGNAL_TYPE" in | ||
| recovery|standby) FILE="/data/pgdata/${SIGNAL_TYPE}.signal" ;; | ||
| *) | ||
| echo "error: unknown signal type '${SIGNAL_TYPE}'; expected recovery or standby" >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| case "$ACTION" in | ||
| create) exec /usr/bin/touch "${FILE}" ;; | ||
| remove) exec /usr/bin/rm -f "${FILE}" ;; | ||
| *) | ||
| echo "error: unknown action '${ACTION}'; expected create or remove" >&2 | ||
| exit 1 | ||
| ;; | ||
| esac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.