-
-
Notifications
You must be signed in to change notification settings - Fork 198
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
Changes from 36 commits
2f2862e
a9497e0
116cb57
c37826b
249c69f
b8ced22
4073448
aaf657a
0b7eb6d
a7db18e
a1f6444
e2de144
0d284a5
759ff9d
c6394aa
a8b7e24
8a76794
2858abc
e6b80eb
9a0becb
ef4bec3
d12cea6
cb94a41
a3608fe
aa3e4d4
8e8fa4c
cc1d0e8
2aa9ddd
16e2f4a
460ca54
55d4263
efc0149
35d7980
8f57dc0
8c2184e
e7d1c87
7ace90c
96c7b34
992dcb3
a7a9679
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,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" |
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/postgresql.conf | ||
sed -i "s/.*recovery_target_time/#recovery_target_time/" /etc/postgresql/postgresql.conf | ||
sed -i "s/.*recovery_target_action/#recovery_target_action/" /etc/postgresql/postgresql.conf | ||
|
||
# enable archive_command | ||
sed -i "s/.*archive_mode/archive_mode/" /etc/postgresql/postgresql.conf | ||
sed -i "s/.*archive_command/archive_command/" /etc/postgresql/postgresql.conf | ||
sed -i "s/.*archive_timeout/archive_timeout/" /etc/postgresql/postgresql.conf | ||
|
||
systemctl restart postgresql | ||
|
||
echo "Cleanup post WAL-G restoration complete" |
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/postgresql.conf | ||
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. Instead of modifying this conf file, what do you think of including a separate file, and writing to it/emptying it out to enable/disable wal-g? 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. Updated to |
||
sed -i "s/.*archive_command/#archive_command/" /etc/postgresql/postgresql.conf | ||
sed -i "s/.*archive_timeout/#archive_timeout/" /etc/postgresql/postgresql.conf | ||
|
||
systemctl restart postgresql | ||
|
||
echo "WAL-G successfully disabled" |
Original file line number | Diff 57AE 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/postgresql.conf | ||
sed -i "s/.*archive_command/archive_command/" /etc/postgresql/postgresql.conf | ||
sed -i "s/.*archive_timeout/archive_timeout/" /etc/postgresql/postgresql.conf | ||
|
||
systemctl restart postgresql | ||
|
||
echo "WAL-G successfully enabled" |
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 | ||
} |
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,41 @@ | |
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' | ||
|
||
# Clean up Go | ||
- name: Uninstall Go | ||
become: yes | ||
|
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: