add enable/disable backup support

This commit is contained in:
ace 2023-07-04 00:02:28 +03:00
parent 72bd38d417
commit 0cca5cba39
Signed by: ace
GPG Key ID: 2C08973DD37A76FD
7 changed files with 14 additions and 6 deletions

View File

@ -2,6 +2,9 @@ wal_g_version: "2.0.1"
wal_g_install_repo: true
wal_g_pg: false
wal_g_pg_binary_name: "wal-g-pg"
wal_g_pg_user: "postgres"
wal_g_pg_database: "postgres"
wal_g_restore: false
wal_g_config_name: ".walg.json"
wal_g_restore_config_name: ".walg-restore.json"
@ -12,6 +15,7 @@ wal_g_pg_backup_owner: "postgres"
wal_g_pg_backup_group: "postgres"
wal_g_pg_major_version: "15"
wal_g_backup_enable: false
wal_g_backup_schedule: ""
wal_g_backup_retention_schedule: ""
wal_g_backup_retention_number: 7
@ -35,6 +39,8 @@ wal_g_default_config: # more options see https://github.com/wal-g/wal-g#configu
WALG_COMPRESSION_METHOD: "brotli"
PGDATA: "{{ wal_g_pg_data_dir }}"
PGHOST: "/var/run/postgresql"
PGUSER: "{{ wal_g_pg_user }}"
PGDATABASE: "{{ wal_g_pg_database }}"
# WALG_LIBSODIUM_KEY: "d82560ddab2b096c56ea8c6573dfdf29de8cd6f2bb5e672d1d3b5a89749b8cbd"
WALG_LIBSODIUM_KEY_TRANSFORM: "hex"
@ -42,4 +48,6 @@ wal_g_default_restore_config:
WALG_COMPRESSION_METHOD: "brotli"
PGDATA: "{{ wal_g_pg_data_dir }}"
PGHOST: "/var/run/postgresql"
PGUSER: "{{ wal_g_pg_user }}"
PGDATABASE: "{{ wal_g_pg_database }}"
WALG_LIBSODIUM_KEY_TRANSFORM: "hex"

View File

@ -8,7 +8,7 @@
- name: Enable and start systemd backup timer
systemd:
name: backup.timer
enabled: yes
enabled: "{{ 'yes' if wal_g_backup_enable else 'no' }}"
masked: no
state: started
daemon_reload: yes

View File

@ -8,7 +8,7 @@
- name: Enable and start systemd backup permanent timer
systemd:
name: backup-permanent.timer
enabled: yes
enabled: "{{ 'yes' if wal_g_backup_enable else 'no' }}"
masked: no
state: started
daemon_reload: yes

View File

@ -8,7 +8,7 @@
- name: Enable and start systemd backup retention timer
systemd:
name: backup-retention.timer
enabled: yes
enabled: "{{ 'yes' if wal_g_backup_enable else 'no' }}"
masked: no
state: started
daemon_reload: yes

View File

@ -4,7 +4,7 @@ flock -x 200
role=$(curl -k -s http://127.0.0.1:8008 || curl -k -s https://127.0.0.1:8008 | jq '.role')
if [ "${role}" == "\"master\"" ] ; then
if [ "${role}" == "\"master\"" ] || [ "${role}" == "" ]; then
{% if wal_g_http_proxy is defined %}http_proxy={{ wal_g_http_proxy }} {% else %}{% endif %}{% if wal_g_https_proxy is defined %}https_proxy={{ wal_g_https_proxy }} {% elif wal_g_http_proxy is defined %}https_proxy={{ wal_g_http_proxy }}{% else %}{% endif %} {{ wal_g_pg_binary_name }} --config {{ wal_g_pg_home_dir }}/{{ wal_g_config_name }} backup-push {{ wal_g_pg_data_dir }} --full --permanent 2>&1 | tee -a /var/log/postgresql/backup-permanent.log
else
echo ""

View File

@ -3,7 +3,7 @@ flock -x 200
role=$(curl -k -s http://127.0.0.1:8008 || curl -k -s https://127.0.0.1:8008 | jq '.role')
if [ "${role}" == "\"master\"" ] ; then
if [ "${role}" == "\"master\"" ] || [ "${role}" == "" ]; then
{% if wal_g_http_proxy is defined %}http_proxy={{ wal_g_http_proxy }} {% else %}{% endif %}{% if wal_g_https_proxy is defined %}https_proxy={{ wal_g_https_proxy }} {% elif wal_g_http_proxy is defined %}https_proxy={{ wal_g_http_proxy }}{% else %}{% endif %} {{ wal_g_pg_binary_name }} --config {{ wal_g_pg_home_dir }}/{{ wal_g_config_name }} retain {{ wal_g_backup_retention_number }} --confirm --use-sentinel-time 2>&1 | tee -a /var/log/postgresql/backup-retention.log
else
echo ""

View File

@ -3,7 +3,7 @@ flock -x 200
role=$(curl -k -s http://127.0.0.1:8008 || curl -k -s https://127.0.0.1:8008 | jq '.role')
if [ "${role}" == "\"master\"" ] ; then
if [ "${role}" == "\"master\"" ] || [ "${role}" == "" ]; then
{% if wal_g_http_proxy is defined %}http_proxy={{ wal_g_http_proxy }} {% else %}{% endif %}{% if wal_g_https_proxy is defined %}https_proxy={{ wal_g_https_proxy }} {% elif wal_g_http_proxy is defined %}https_proxy={{ wal_g_http_proxy }}{% else %}{% endif %} {{ wal_g_pg_binary_name }} --config {{ wal_g_pg_home_dir }}/{{ wal_g_config_name }} backup-push {{ wal_g_pg_data_dir }} --full 2>&1 | tee -a /var/log/postgresql/backup.log
else
echo ""