r/wal-g-pg: Schedule daily backups

WAL archives are not much good without a base backup onto which they
can be applied.  Thus, we need to schedule WAL-G to create and upload a
backup periodically.
frigate-exporter
Dustin 2024-07-02 11:54:41 -05:00
parent b83c6de28a
commit 090ebb0c1b
5 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,2 @@
wal_g_pg_backup_timer_schedule: >-
*-*-* 03:56

View File

@ -0,0 +1,9 @@
[Unit]
Description=PostgreSQL Backup with WAL-G
Wants=network-online.target
After=network-online.target
[Service]
Type=oneshot
Environment=PGDATA=/var/lib/pgsql/data
ExecStart=/usr/bin/wal-g-pg backup-push --config /etc/postgresql/wal-g.yml $PGDATA

View File

@ -1,3 +1,8 @@
- name: load wal-g-postgresql selinux module - name: load wal-g-postgresql selinux module
command: command:
semodule -i /usr/local/share/selinux/wal-g-postgresql.cil semodule -i /usr/local/share/selinux/wal-g-postgresql.cil
- name: restart wal-g backup timer
systemd:
name: wal-g-backup.timer
state: restarted

View File

@ -34,5 +34,40 @@
tags: tags:
- selinux - selinux
- name: ensure wal-g backup timer is installed
template:
src: wal-g-backup.timer.j2
dest: /etc/systemd/system/wal-g-backup.timer
owner: root
group: root
mode: u=rw,go=r
notify:
- restart wal-g backup timer
tags:
- systemd
- name: ensure wal-g backup service is installed
copy:
src: wal-g-backup.service
dest: /etc/systemd/system/wal-g-backup.service
owner: root
group: root
mode: u=rw,go=r
tags:
- systemd
- name: ensure wal-g backup timer is enabled
systemd:
name: wal-g-backup.timer
enabled: true
tags:
- service
- name: flush handlers - name: flush handlers
meta: flush_handlers meta: flush_handlers
- name: ensure wal-g backup timer is running
systemd:
name: wal-g-backup.timer
state: started
tags:
- service

View File

@ -0,0 +1,9 @@
[Unit]
Description=Daily PostgreSQL backup with WAL-G
[Timer]
OnCalendar={{ wal_g_pg_backup_timer_schedule }}
Persistent=yes
[Install]
WantedBy=timers.target