mirror of
				https://gitea.0xace.cc/ansible-galaxy/wal-g-pg.git
				synced 2025-11-04 03:17:23 +00:00 
			
		
		
		
	support enable/disable backups
This commit is contained in:
		@@ -2,7 +2,7 @@ wal_g_version: "3.0.0"
 | 
				
			|||||||
wal_g_install_repo: true
 | 
					wal_g_install_repo: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wal_g_pg: false
 | 
					wal_g_pg: false
 | 
				
			||||||
wal_g_pg_binary_name: "wal-g-pg"
 | 
					wal_g_pg_binary: "/usr/bin/wal-g-pg"
 | 
				
			||||||
wal_g_pg_user: "postgres"
 | 
					wal_g_pg_user: "postgres"
 | 
				
			||||||
wal_g_pg_database: "postgres"
 | 
					wal_g_pg_database: "postgres"
 | 
				
			||||||
wal_g_restore: false
 | 
					wal_g_restore: false
 | 
				
			||||||
@@ -15,10 +15,12 @@ wal_g_pg_backup_group: "postgres"
 | 
				
			|||||||
wal_g_pg_major_version: "15"
 | 
					wal_g_pg_major_version: "15"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wal_g_backup_enable: true
 | 
					wal_g_backup_enable: true
 | 
				
			||||||
wal_g_backup_schedule: ""
 | 
					wal_g_backup_schedule: "*-*-* 00:00:00"
 | 
				
			||||||
wal_g_backup_retention_schedule: ""
 | 
					wal_g_backup_permanent_enable: false
 | 
				
			||||||
 | 
					wal_g_backup_permanent_schedule: "*-*-* 05:00:00"
 | 
				
			||||||
 | 
					wal_g_backup_retention_enable: false
 | 
				
			||||||
 | 
					wal_g_backup_retention_schedule: "*-*-* 10:00:00"
 | 
				
			||||||
wal_g_backup_retention_number: 7
 | 
					wal_g_backup_retention_number: 7
 | 
				
			||||||
wal_g_backup_permanent_schedule: ""
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# If backuping through proxy
 | 
					# If backuping through proxy
 | 
				
			||||||
#wal_g_http_proxy: ''
 | 
					#wal_g_http_proxy: ''
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
---
 | 
					---
 | 
				
			||||||
galaxy_info:
 | 
					galaxy_info:
 | 
				
			||||||
  description: WAL-G role for PostgreSQL
 | 
					  description: WAL-G backup util
 | 
				
			||||||
  galaxy_tags:
 | 
					  galaxy_tags:
 | 
				
			||||||
  - wal-g-pg
 | 
					  - wal-g
 | 
				
			||||||
 | 
					
 | 
				
			||||||
dependencies: []
 | 
					dependencies: []
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,4 +19,4 @@
 | 
				
			|||||||
    enabled: no
 | 
					    enabled: no
 | 
				
			||||||
    masked: no
 | 
					    masked: no
 | 
				
			||||||
    daemon_reload: yes
 | 
					    daemon_reload: yes
 | 
				
			||||||
  when: not backup_service.changed
 | 
					  when: backup_service.changed
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,6 +10,5 @@
 | 
				
			|||||||
    name: backup.timer
 | 
					    name: backup.timer
 | 
				
			||||||
    enabled: "{{ 'yes' if wal_g_backup_enable else 'no' }}"
 | 
					    enabled: "{{ 'yes' if wal_g_backup_enable else 'no' }}"
 | 
				
			||||||
    masked: no
 | 
					    masked: no
 | 
				
			||||||
    state: started
 | 
					    state: "{{ 'started' if wal_g_backup_enable else 'stopped' }}"
 | 
				
			||||||
    daemon_reload: yes
 | 
					    daemon_reload: yes
 | 
				
			||||||
  when: not backup_timer.changed
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,4 +19,4 @@
 | 
				
			|||||||
    enabled: no
 | 
					    enabled: no
 | 
				
			||||||
    masked: no
 | 
					    masked: no
 | 
				
			||||||
    daemon_reload: yes
 | 
					    daemon_reload: yes
 | 
				
			||||||
  when: not backup_permanent_service.changed
 | 
					  when: backup_permanent_service.changed
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,8 +8,7 @@
 | 
				
			|||||||
- name: Enable and start systemd backup permanent timer
 | 
					- name: Enable and start systemd backup permanent timer
 | 
				
			||||||
  systemd:
 | 
					  systemd:
 | 
				
			||||||
    name: backup-permanent.timer
 | 
					    name: backup-permanent.timer
 | 
				
			||||||
    enabled: "{{ 'yes' if wal_g_backup_enable else 'no' }}"
 | 
					    enabled: "{{ 'yes' if wal_g_backup_permanent_enable else 'no' }}"
 | 
				
			||||||
    masked: no
 | 
					    masked: no
 | 
				
			||||||
    state: started
 | 
					    state: "{{ 'started' if wal_g_backup_permanent_enable else 'stopped' }}"
 | 
				
			||||||
    daemon_reload: yes
 | 
					    daemon_reload: yes
 | 
				
			||||||
  when: not backup_permanent_timer.changed
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,5 +19,4 @@
 | 
				
			|||||||
    enabled: no
 | 
					    enabled: no
 | 
				
			||||||
    masked: no
 | 
					    masked: no
 | 
				
			||||||
    daemon_reload: yes
 | 
					    daemon_reload: yes
 | 
				
			||||||
  when: not backup_retention_service.changed
 | 
					  when: backup_retention_service.changed
 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,8 +8,7 @@
 | 
				
			|||||||
- name: Enable and start systemd backup retention timer
 | 
					- name: Enable and start systemd backup retention timer
 | 
				
			||||||
  systemd:
 | 
					  systemd:
 | 
				
			||||||
    name: backup-retention.timer
 | 
					    name: backup-retention.timer
 | 
				
			||||||
    enabled: "{{ 'yes' if wal_g_backup_enable else 'no' }}"
 | 
					    enabled: "{{ 'yes' if wal_g_backup_retention_enable else 'no' }}"
 | 
				
			||||||
    masked: no
 | 
					    masked: no
 | 
				
			||||||
    state: started
 | 
					    state: "{{ 'started' if wal_g_backup_retention_enable else 'stopped' }}"
 | 
				
			||||||
    daemon_reload: yes
 | 
					    daemon_reload: yes
 | 
				
			||||||
  when: not backup_retention_timer.changed
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,40 +17,22 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
- name: "Include install WAL-G {{ wal_g_version }} for PostgreSQL"
 | 
					- name: "Include install WAL-G {{ wal_g_version }} for PostgreSQL"
 | 
				
			||||||
  include_tasks: pg.yaml
 | 
					  include_tasks: pg.yaml
 | 
				
			||||||
  when: wal_g_pg
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: "Include backup job with WAL-G {{ wal_g_version }} for PostgreSQL"
 | 
					- name: "Include backup job with WAL-G {{ wal_g_version }} for PostgreSQL"
 | 
				
			||||||
  include_tasks: backup_job.yaml
 | 
					  include_tasks: backup_job.yaml
 | 
				
			||||||
  when:
 | 
					 | 
				
			||||||
    - wal_g_pg
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: "Include backup job timer with WAL-G {{ wal_g_version }} for PostgreSQL"
 | 
					- name: "Include backup job timer with WAL-G {{ wal_g_version }} for PostgreSQL"
 | 
				
			||||||
  include_tasks: backup_job_timer.yaml
 | 
					  include_tasks: backup_job_timer.yaml
 | 
				
			||||||
  when:
 | 
					 | 
				
			||||||
    - wal_g_pg
 | 
					 | 
				
			||||||
    - wal_g_backup_schedule is defined
 | 
					 | 
				
			||||||
    - wal_g_backup_schedule | length > 0
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- name: "Include backup retention job with WAL-G {{ wal_g_version }} for PostgreSQL"
 | 
					 | 
				
			||||||
  include_tasks: backup_retention_job.yaml
 | 
					 | 
				
			||||||
  when:
 | 
					 | 
				
			||||||
    - wal_g_pg
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- name: "Include backup retention job timer with WAL-G {{ wal_g_version }} for PostgreSQL"
 | 
					 | 
				
			||||||
  include_tasks: backup_retention_job_timer.yaml
 | 
					 | 
				
			||||||
  when:
 | 
					 | 
				
			||||||
    - wal_g_pg
 | 
					 | 
				
			||||||
    - wal_g_backup_retention_schedule is defined
 | 
					 | 
				
			||||||
    - wal_g_backup_retention_schedule | length > 0
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: "Include permanent backup job with WAL-G {{ wal_g_version }} for PostgreSQL"
 | 
					- name: "Include permanent backup job with WAL-G {{ wal_g_version }} for PostgreSQL"
 | 
				
			||||||
  include_tasks: backup_permanent_job.yaml
 | 
					  include_tasks: backup_permanent_job.yaml
 | 
				
			||||||
  when:
 | 
					 | 
				
			||||||
    - wal_g_pg
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: "Include permanent backup job timer with WAL-G {{ wal_g_version }} for PostgreSQL"
 | 
					- name: "Include permanent backup job timer with WAL-G {{ wal_g_version }} for PostgreSQL"
 | 
				
			||||||
  include_tasks: backup_permanent_job_timer.yaml
 | 
					  include_tasks: backup_permanent_job_timer.yaml
 | 
				
			||||||
  when:
 | 
					
 | 
				
			||||||
    - wal_g_pg
 | 
					- name: "Include backup retention job with WAL-G {{ wal_g_version }} for PostgreSQL"
 | 
				
			||||||
    - wal_g_backup_permanent_schedule is defined
 | 
					  include_tasks: backup_retention_job.yaml
 | 
				
			||||||
    - wal_g_backup_permanent_schedule | length > 0
 | 
					
 | 
				
			||||||
 | 
					- name: "Include backup retention job timer with WAL-G {{ wal_g_version }} for PostgreSQL"
 | 
				
			||||||
 | 
					  include_tasks: backup_retention_job_timer.yaml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,7 +5,7 @@ role=$(curl -k -s http://127.0.0.1:8008 || curl -k -s https://127.0.0.1:8008 | j
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ "${role}" == "\"master\"" ] || [ "${role}" == "" ]; 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
 | 
					  {% 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 }} --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
 | 
					else
 | 
				
			||||||
  echo ""
 | 
					  echo ""
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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')
 | 
					role=$(curl -k -s http://127.0.0.1:8008 || curl -k -s https://127.0.0.1:8008 | jq '.role')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ "${role}" == "\"master\"" ] || [ "${role}" == "" ]; 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 }} delete 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 }} {% elif wal_g_http_proxy is defined %}https_proxy={{ wal_g_http_proxy }}{% else %}{% endif %} {{ wal_g_pg_binary }} --config {{ wal_g_pg_home_dir }}/{{ wal_g_config_name }} delete retain {{ wal_g_backup_retention_number }} --confirm --use-sentinel-time 2>&1 | tee -a /var/log/postgresql/backup-retention.log
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
  echo ""
 | 
					  echo ""
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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')
 | 
					role=$(curl -k -s http://127.0.0.1:8008 || curl -k -s https://127.0.0.1:8008 | jq '.role')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ "${role}" == "\"master\"" ] || [ "${role}" == "" ]; 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
 | 
					  {% 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 }} --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
 | 
					else
 | 
				
			||||||
  echo ""
 | 
					  echo ""
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user