-
-
Notifications
You must be signed in to change notification settings - Fork 237
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| /var/log/pgbackrest/*.log { | ||
| daily | ||
| rotate 7 | ||
| compress | ||
| delaycompress | ||
| missingok | ||
| notifempty | ||
| create 0660 pgbackrest postgres | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/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) | ||
| exec /usr/bin/chown -R pgbackrest:pgbackrest "$REAL" | ||
| ;; | ||
| to-postgres) | ||
| exec /usr/bin/chown -R postgres:postgres "$REAL" | ||
| ;; | ||
| *) | ||
| echo "error: unknown action '${ACTION}'; expected to-pgbackrest or to-postgres" >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,35 @@ | ||||||||||||
| #!/usr/bin/env bash | ||||||||||||
| # pgdata-signal — creates or removes PostgreSQL recovery/standby signal files. | ||||||||||||
| # Called via sudo (as postgres) by supabase-admin-agent (running as adminapi). | ||||||||||||
| # | ||||||||||||
| # Signal file paths are hardcoded to prevent path injection. No external | ||||||||||||
| # path argument is accepted. | ||||||||||||
| # | ||||||||||||
| # Usage: pgdata-signal <create|remove> <recovery|standby> | ||||||||||||
| set -euo pipefail | ||||||||||||
|
|
||||||||||||
| if [[ $# -ne 2 ]]; then | ||||||||||||
| echo "usage: pgdata-signal <create|remove> <recovery|standby>" >&2 | ||||||||||||
| exit 1 | ||||||||||||
| fi | ||||||||||||
|
|
||||||||||||
| ACTION="$1" | ||||||||||||
| SIGNAL_TYPE="$2" | ||||||||||||
|
|
||||||||||||
| case "$SIGNAL_TYPE" in | ||||||||||||
| recovery) FILE="/data/pgdata/recovery.signal" ;; | ||||||||||||
| standby) FILE="/data/pgdata/standby.signal" ;; | ||||||||||||
|
Comment on lines
+20
to
+21
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| *) | ||||||||||||
| 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" ;; | ||||||||||||
|
Comment on lines
+28
to
+30
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you make ACTION either touch or rm then you can:
Suggested change
|
||||||||||||
| *) | ||||||||||||
| echo "error: unknown action '${ACTION}'; expected create or remove" >&2 | ||||||||||||
| exit 1 | ||||||||||||
| ;; | ||||||||||||
| esac | ||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -48,7 +48,6 @@ | |||||||||||||||||||||||||
| path: "{{ backrest_dir }}" | ||||||||||||||||||||||||||
| state: directory | ||||||||||||||||||||||||||
| loop: | ||||||||||||||||||||||||||
| - /etc/pgbackrest/conf.d | ||||||||||||||||||||||||||
| - /var/lib/pgbackrest | ||||||||||||||||||||||||||
| - /var/spool/pgbackrest | ||||||||||||||||||||||||||
| - /var/log/pgbackrest | ||||||||||||||||||||||||||
|
|
@@ -57,6 +56,16 @@ | |||||||||||||||||||||||||
| when: | ||||||||||||||||||||||||||
| - nixpkg_mode | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: Create pgBackRest conf.d directory with setgid | ||||||||||||||||||||||||||
| ansible.legacy.file: | ||||||||||||||||||||||||||
| group: postgres | ||||||||||||||||||||||||||
| mode: '02770' | ||||||||||||||||||||||||||
| owner: pgbackrest | ||||||||||||||||||||||||||
| path: /etc/pgbackrest/conf.d | ||||||||||||||||||||||||||
| state: directory | ||||||||||||||||||||||||||
| when: | ||||||||||||||||||||||||||
| - nixpkg_mode | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: Symlink pgbackrest.conf | ||||||||||||||||||||||||||
| ansible.legacy.file: | ||||||||||||||||||||||||||
| force: true | ||||||||||||||||||||||||||
|
|
@@ -82,6 +91,14 @@ | |||||||||||||||||||||||||
| when: | ||||||||||||||||||||||||||
| - stage2_nix | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: pgBackRest - logrotate config | ||||||||||||||||||||||||||
| ansible.legacy.copy: | ||||||||||||||||||||||||||
| src: files/pgbackrest_config/pgbackrest.logrotate | ||||||||||||||||||||||||||
| dest: /etc/logrotate.d/pgbackrest | ||||||||||||||||||||||||||
| owner: root | ||||||||||||||||||||||||||
| group: root | ||||||||||||||||||||||||||
| mode: '0644' | ||||||||||||||||||||||||||
|
Comment on lines
+95
to
+100
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: Create pgBackRest wrapper script | ||||||||||||||||||||||||||
| ansible.builtin.copy: | ||||||||||||||||||||||||||
| content: | | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we've been setting everything to group postgres thus far
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pgBackRest binary in the wrapper is executed as the
pgbackrestuser so the PGDATA path needs to be altered for restores and relics setup.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i get that. it'd still be owner pgbackrest with my change?