Files
PostgreSQL-Ansible/roles/restore_primary/tasks/main.yml
2026-01-29 12:55:01 +01:00

20 lines
407 B
YAML

- name: Stop postgres on primary
service:
name: postgresql
state: stopped
- name: Remove old data on primary
file:
path: "{{ pg_data }}"
state: absent
- name: Restore base backup from replica
become_user: postgres
command: >
pg_basebackup -h pg2 -D {{ pg_data }} -U replicator -Fp -Xs -P -R
- name: Start postgres on primary
service:
name: postgresql
state: started