From e1c5f252ed4df693679c00b845a69dc707f96abc Mon Sep 17 00:00:00 2001 From: ace Date: Thu, 11 May 2023 13:56:29 +0300 Subject: [PATCH] add proxy support --- defaults/main.yaml | 4 ++++ templates/backup-permanent.sh.j2 | 3 ++- templates/backup-retention.sh.j2 | 2 +- templates/backup.sh.j2 | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/defaults/main.yaml b/defaults/main.yaml index 4efba5d..09130cf 100644 --- a/defaults/main.yaml +++ b/defaults/main.yaml @@ -17,6 +17,10 @@ wal_g_backup_retention_schedule: "" wal_g_backup_retention_number: 7 wal_g_backup_permanent_schedule: "" +# If backuping through proxy +#wal_g_http_proxy: '' +#wal_g_https_proxy: '' + wal_g_postgresql_supported_versions: - 13 - 14 diff --git a/templates/backup-permanent.sh.j2 b/templates/backup-permanent.sh.j2 index 377d875..502857f 100644 --- a/templates/backup-permanent.sh.j2 +++ b/templates/backup-permanent.sh.j2 @@ -3,8 +3,9 @@ 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 - {{ 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 + {% 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 }} {% 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 "" fi diff --git a/templates/backup-retention.sh.j2 b/templates/backup-retention.sh.j2 index 31d125d..9fd570e 100644 --- a/templates/backup-retention.sh.j2 +++ b/templates/backup-retention.sh.j2 @@ -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 - {{ 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 + {% 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 }} {% 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 "" fi diff --git a/templates/backup.sh.j2 b/templates/backup.sh.j2 index dc4cc02..925d709 100644 --- a/templates/backup.sh.j2 +++ b/templates/backup.sh.j2 @@ -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 - {{ 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 + {% 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 }} {% 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 "" fi