v1.0
This commit is contained in:
37
roles/pgbackrest/tasks/main.yml
Normal file
37
roles/pgbackrest/tasks/main.yml
Normal file
@@ -0,0 +1,37 @@
|
||||
- name: Install pgBackRest
|
||||
apt:
|
||||
name: pgbackrest
|
||||
state: present
|
||||
|
||||
- name: Repo dir
|
||||
file:
|
||||
path: /pgbackrest
|
||||
state: directory
|
||||
owner: postgres
|
||||
mode: "750"
|
||||
when: inventory_hostname in groups['replica']
|
||||
|
||||
- name: Config
|
||||
template:
|
||||
src: pgbackrest.conf.j2
|
||||
dest: /etc/pgbackrest.conf
|
||||
|
||||
- name: Create stanza
|
||||
become_user: postgres
|
||||
command: pgbackrest --stanza=main stanza-create
|
||||
when: inventory_hostname in groups['primary']
|
||||
|
||||
- name: Full backup weekly
|
||||
cron:
|
||||
name: "pgbackrest full"
|
||||
weekday: 0
|
||||
hour: 2
|
||||
minute: 0
|
||||
job: "pgbackrest --stanza=main backup --type=full"
|
||||
|
||||
- name: Incremental backup daily
|
||||
cron:
|
||||
name: "pgbackrest incr"
|
||||
hour: 2
|
||||
minute: 0
|
||||
job: "pgbackrest --stanza=main backup --type=incr"
|
||||
11
roles/pgbackrest/templates/pgbackrest.conf.j2
Normal file
11
roles/pgbackrest/templates/pgbackrest.conf.j2
Normal file
@@ -0,0 +1,11 @@
|
||||
[main]
|
||||
pg1-path=/var/lib/postgresql/16/main
|
||||
|
||||
[global]
|
||||
{% if inventory_hostname in groups['primary'] %}
|
||||
repo1-host=pg2
|
||||
{% endif %}
|
||||
repo1-path=/pgbackrest
|
||||
repo1-retention-full=2
|
||||
repo1-retention-diff=7
|
||||
start-fast=y
|
||||
Reference in New Issue
Block a user