-
-
Notifications
You must be signed in to change notification settings - Fork 189
Implement configurations for WAL-G #145
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
Merged
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
2f2862e
chore: create wal-g Linux user
dragarcia a9497e0
Revert WAL-G backport
dragarcia 116cb57
chore: give read access to PG data directory to groups
dragarcia c37826b
update configs in postgresql.conf
dragarcia 249c69f
WAL-G specific scripts to be triggered via the admin API
dragarcia b8ced22
Create config directory for wal-g
dragarcia 4073448
chore: add logging for wal-g processes
dragarcia aaf657a
ensure bindir when installing pgsodium works for EC2 builds
dragarcia 0b7eb6d
triggere dockerbuild
dragarcia a7db18e
Run backup in background
dragarcia a1f6444
Inject WALG_SENTINEL_USER_DATA during backups
dragarcia e2de144
Add scripts for enabling and disabling walg
dragarcia 0d284a5
removed unused scripts
dragarcia 759ff9d
Merge branch 'develop' of github.com:supabase/postgres into chore/wal…
dragarcia c6394aa
bump versioning
dragarcia a8b7e24
cleanup
dragarcia 8a76794
Move logrotate to its own dir
dragarcia 2858abc
cleanup: loop through creation of log files
dragarcia e6b80eb
set up logrotate for all WAL-G log files
dragarcia 9a0becb
Ensure backup is pointing to the correct log file
dragarcia ef4bec3
Merge branch 'fix/dockerbuild_bin_dir' of github.com:supabase/postgre…
dragarcia d12cea6
create postgres linux group
dragarcia cb94a41
ensure that it's config.json, not .env
dragarcia a3608fe
allow admin API to edit /etc/wal-g/config.json
dragarcia aa3e4d4
Merge branch 'develop' of github.com:supabase/postgres into chore/wal…
dragarcia 8e8fa4c
add whitespace
dragarcia cc1d0e8
script to complete wal-g restoration
dragarcia 2aa9ddd
Merge branch 'develop' of github.com:supabase/postgres into chore/wal…
dragarcia 16e2f4a
update adminapi
dragarcia 460ca54
remove bindir in setup-system
dragarcia 55d4263
create wal-g group and move up setting up of wal-g
dragarcia efc0149
create wal-g log files towards the end
dragarcia 35d7980
Ensure /var/lib/postgresql/data is owned by postgres:postgres
dragarcia 8f57dc0
fix transfer of file found in subdirectories
dragarcia 8c2184e
set primary groups for postgres and wal-g linux users
dragarcia e7d1c87
Merge branch 'develop' of github.com:supabase/postgres into chore/wal…
dragarcia 7ace90c
newline
dragarcia 96c7b34
modify wal-g related parameters in separate file
dragarcia 992dcb3
bump to 14.1.0.21
dragarcia a7a9679
more newlines
dragarcia 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#! /usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
WALG_SENTINEL_USER_DATA="{ \"backup_id\": $1, \"project_id\": $2 }" nohup wal-g backup-push /var/lib/postgresql/data --config /etc/wal-g/config.json --verify >> /var/log/wal-g/backup-push.log 2>&1 & | ||
|
||
echo "WAL-G backup job commenced" |
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,26 @@ | ||
#! /usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# disable 169.254.169.254 for postgres | ||
sed -i "/#\\sdon't\\sdelete\\sthe\\s'COMMIT'/ i -I OUTPUT 1 --proto tcp --destination 169.254.169.254 --match owner --uid-owner postgres --jump REJECT\\n" /etc/ufw/before.rules | ||
ufw reload | ||
|
||
# move config file to its final location and change its ownership | ||
mv /etc/postgresql/wal-g-config.json /etc/wal-g/config.json | ||
chown wal-g:wal-g /etc/wal-g/config.json | ||
|
||
|
||
# disable recovery commands in the event of a restart | ||
sed -i "s/.*restore_command/#restore_command/" /etc/postgresql-custom/wal-g.conf | ||
sed -i "s/.*recovery_target_time/#recovery_target_time/" /etc/postgresql-custom/wal-g.conf | ||
sed -i "s/.*recovery_target_action/#recovery_target_action/" /etc/postgresql-custom/wal-g.conf | ||
|
||
# enable archive_command | ||
sed -i "s/.*archive_mode/archive_mode/" /etc/postgresql-custom/wal-g.conf | ||
sed -i "s/.*archive_command/archive_command/" /etc/postgresql-custom/wal-g.conf | ||
sed -i "s/.*archive_timeout/archive_timeout/" /etc/postgresql-custom/wal-g.conf | ||
|
||
systemctl restart postgresql | ||
|
||
echo "Cleanup post WAL-G restoration complete" |
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,11 @@ | ||
#! /usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
sed -i "s/.*archive_mode/#archive_mode/" /etc/postgresql-custom/wal-g.conf | ||
sed -i "s/.*archive_command/#archive_command/" /etc/postgresql-custom/wal-g.conf | ||
sed -i "s/.*archive_timeout/#archive_timeout/" /etc/postgresql-custom/wal-g.conf | ||
|
||
systemctl restart postgresql | ||
|
||
echo "WAL-G successfully disabled" |
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,11 @@ | ||
#! /usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
sed -i "s/.*archive_mode/archive_mode/" /etc/postgresql-custom/wal-g.conf | ||
sed -i "s/.*archive_command/archive_command/" /etc/postgresql-custom/wal-g.conf | ||
sed -i "s/.*archive_timeout/archive_timeout/" /etc/postgresql-custom/wal-g.conf | ||
|
||
systemctl restart postgresql | ||
|
||
echo "WAL-G successfully enabled" |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,9 @@ | ||
/var/log/wal-g/*.log { | ||
size 50M | ||
rotate 3 | ||
copytruncate | ||
delaycompress | ||
compress | ||
notifempty | ||
missingok | ||
} |
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,16 @@ | ||
# - Archiving - | ||
|
||
#archive_mode = on | ||
#archive_command = 'sudo -u wal-g wal-g wal-push %p --config /etc/wal-g/config.json >> /var/log/wal-g/wal-push.log 2>&1' | ||
#archive_timeout = 120 | ||
|
||
|
||
# - Archive Recovery - | ||
|
||
#restore_command = 'sudo -u wal-g wal-g wal-fetch "%f" "%p" --config /etc/wal-g/config.json >> /var/log/wal-g/wal-fetch.log 2>&1' | ||
|
||
|
||
# - Recovery Target - | ||
|
||
#recovery_target_time = '' | ||
#recovery_target_action = 'promote' |
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
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 |
---|---|---|
|
@@ -24,7 +24,7 @@ | |
# Download WAL-G | ||
- name: wal-g - download latest version | ||
git: | ||
repo: https://github.com/darora/wal-g.git | ||
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. 😿 |
||
repo: https://github.com/wal-g/wal-g.git | ||
dest: /tmp/wal-g | ||
version: "{{ wal_g_release }}" | ||
become: yes | ||
|
@@ -61,6 +61,56 @@ | |
USE_LIBSODIUM: true | ||
become: yes | ||
|
||
- name: Create wal-g group | ||
group: | ||
name: wal-g | ||
state: present | ||
|
||
- name: Create wal-g user | ||
user: | ||
name: wal-g | ||
shell: /bin/false | ||
comment: WAL-G user | ||
group: wal-g | ||
groups: wal-g, postgres | ||
|
||
- name: Give postgres access to execute wal-g binary as wal-g user | ||
copy: | ||
content: | | ||
postgres ALL=(wal-g) NOPASSWD: /usr/local/bin/wal-g | ||
dest: /etc/sudoers.d/postgres | ||
|
||
- name: Create a config directory owned by wal-g | ||
file: | ||
path: /etc/wal-g | ||
state: directory | ||
owner: wal-g | ||
group: wal-g | ||
mode: '0760' | ||
|
||
- name: Create /etc/wal-g/config.json | ||
file: | ||
path: /etc/wal-g/config.json | ||
state: touch | ||
owner: wal-g | ||
group: wal-g | ||
mode: '0760' | ||
|
||
- name: Move custom wal-g.conf file to /etc/postgresql-custom/wal-g.conf | ||
template: | ||
src: "files/postgresql_config/custom_walg.conf.j2" | ||
dest: /etc/postgresql-custom/wal-g.conf | ||
mode: 0664 | ||
owner: postgres | ||
group: postgres | ||
|
||
- name: Include /etc/postgresql-custom/wal-g.conf in postgresql.conf | ||
become: yes | ||
replace: | ||
path: /etc/postgresql/postgresql.conf | ||
regexp: "#include = '/etc/postgresql-custom/wal-g.conf'" | ||
replace: "include = '/etc/postgresql-custom/wal-g.conf'" | ||
|
||
# Clean up Go | ||
- name: Uninstall Go | ||
become: yes | ||
|
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"postgres-version": "14.1.0.20" | ||
"postgres-version": "14.1.0.21" | ||
} |
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
Origina E8DF l file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
sudo rm /home/ubuntu/.ssh/authorized_keys | ||
sudo rm /home/ubuntu/.ssh/authorized_keys |
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
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.
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.
just use systemd-cat? Do we expect this to be extremely verbose?
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.
It can get quite verbose depending on the size of the database. For example, this is a full backup done for a ~ 15 GB database.
Also, would want to split the logs for the different
wal-g
sub-commands used: