mirror of
https://gitea.0xace.cc/ansible-galaxy/wal-g-pg.git
synced 2025-06-28 21:23:08 +00:00
first commit
This commit is contained in:
11
templates/backup-permanent.service.j2
Normal file
11
templates/backup-permanent.service.j2
Normal file
@ -0,0 +1,11 @@
|
||||
[Unit]
|
||||
Description=Permanent backup PostgreSQL
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/bash {{ wal_g_pg_home_dir }}/backup-permanent.sh
|
||||
User={{ wal_g_pg_backup_owner }}
|
||||
Group={{ wal_g_pg_backup_group }}
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
13
templates/backup-permanent.sh.j2
Normal file
13
templates/backup-permanent.sh.j2
Normal file
@ -0,0 +1,13 @@
|
||||
exec 200>/tmp/backup.lock
|
||||
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\"" ] || [ "${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 ""
|
||||
fi
|
||||
|
||||
exec 200>&-
|
9
templates/backup-permanent.timer.j2
Normal file
9
templates/backup-permanent.timer.j2
Normal file
@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=Run PostgreSQL backup permanent
|
||||
|
||||
[Timer]
|
||||
Unit=backup-permanent.service
|
||||
OnCalendar={{ wal_g_backup_permanent_schedule }}
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
12
templates/backup-retention.service.j2
Normal file
12
templates/backup-retention.service.j2
Normal file
@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=Backups retention for PostgreSQL
|
||||
Wants=backup-retention.timer
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/bash {{ wal_g_pg_home_dir }}/backup-retention.sh
|
||||
User={{ wal_g_pg_backup_owner }}
|
||||
Group={{ wal_g_pg_backup_group }}
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
12
templates/backup-retention.sh.j2
Normal file
12
templates/backup-retention.sh.j2
Normal file
@ -0,0 +1,12 @@
|
||||
exec 200>/tmp/backup.lock
|
||||
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\"" ] || [ "${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
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
|
||||
exec 200>&-
|
9
templates/backup-retention.timer.j2
Normal file
9
templates/backup-retention.timer.j2
Normal file
@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=Run PostgreSQL backup retention
|
||||
|
||||
[Timer]
|
||||
Unit=backup-retention.service
|
||||
OnCalendar={{ wal_g_backup_retention_schedule }}
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
12
templates/backup.service.j2
Normal file
12
templates/backup.service.j2
Normal file
@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=Backup PostgreSQL
|
||||
Wants=backup.timer
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/bash {{ wal_g_pg_home_dir }}/backup.sh
|
||||
User={{ wal_g_pg_backup_owner }}
|
||||
Group={{ wal_g_pg_backup_group }}
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
12
templates/backup.sh.j2
Normal file
12
templates/backup.sh.j2
Normal file
@ -0,0 +1,12 @@
|
||||
exec 200>/tmp/backup.lock
|
||||
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\"" ] || [ "${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 ""
|
||||
fi
|
||||
|
||||
exec 200>&-
|
9
templates/backup.timer.j2
Normal file
9
templates/backup.timer.j2
Normal file
@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=Run PostgreSQL backup
|
||||
|
||||
[Timer]
|
||||
Unit=backup.service
|
||||
OnCalendar={{ wal_g_backup_schedule }}
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
7
templates/walg.json.j2
Normal file
7
templates/walg.json.j2
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
{% for wal_g in wal_g_json %}
|
||||
"{{ wal_g.option }}": "{{ wal_g.value }}"{% if not loop.last %},
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
}
|
Reference in New Issue
Block a user