aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates
diff options
context:
space:
mode:
authorPaul B <paul@bonaud.fr>2018-12-28 15:30:13 +0100
committerPaul Bonaud <paul.bonaud@fretlink.com>2018-12-28 18:23:19 +0100
commitc95984df57136048002f0d60c6469d9bbbdd1e0a (patch)
treeec16b304ef816d5ab65fd4217bbb8748ffad94fe /templates
parent8371771c8e9b8a2f2a6a4d81a142ddc805e198b4 (diff)
downloadansible-postgresql-role-c95984df57136048002f0d60c6469d9bbbdd1e0a.tar.gz
ansible-postgresql-role-c95984df57136048002f0d60c6469d9bbbdd1e0a.tar.zst
ansible-postgresql-role-c95984df57136048002f0d60c6469d9bbbdd1e0a.zip
standby: rsync from barman is optional if SSH access is already here
Diffstat (limited to 'templates')
-rwxr-xr-xtemplates/standby-clone.sh.j28
1 files changed, 6 insertions, 2 deletions
diff --git a/templates/standby-clone.sh.j2 b/templates/standby-clone.sh.j2
index 3486342..16a6930 100755
--- a/templates/standby-clone.sh.j2
+++ b/templates/standby-clone.sh.j2
@@ -1,6 +1,8 @@
1#!/bin/bash 1#!/bin/bash
2# {{ ansible_managed }} 2# {{ ansible_managed }}
3 3
4set -eo pipefail
5
4BARMAN_DATABASE=$1 6BARMAN_DATABASE=$1
5BARMAN_BACKUP_VERSION=$2 7BARMAN_BACKUP_VERSION=$2
6 8
@@ -17,7 +19,7 @@ echo "accept key if necessary"
17sudo -u postgres ssh barman@{{ postgres_barman_server }} echo "" 19sudo -u postgres ssh barman@{{ postgres_barman_server }} echo ""
18 20
19echo Stopping PostgreSQL 21echo Stopping PostgreSQL
20pg_ctlcluster {{ postgres_version }} {{ postgres_cluster_name }} stop 22pg_ctlcluster {{ postgres_version }} {{ postgres_cluster_name }} stop || true
21 23
22echo Cleaning up old cluster directory 24echo Cleaning up old cluster directory
23sudo -u postgres mv /var/lib/postgresql/{{ postgres_version }}/{{ postgres_cluster_name }}{,_$BACKUP_DATE} 25sudo -u postgres mv /var/lib/postgresql/{{ postgres_version }}/{{ postgres_cluster_name }}{,_$BACKUP_DATE}
@@ -28,8 +30,10 @@ sudo -u postgres mkdir -p /var/lib/postgresql/{{ postgres_version }}/{{ postgres
28echo Get previous backup from backups server 30echo Get previous backup from backups server
29sudo -u postgres \ 31sudo -u postgres \
30 time rsync --progress -pvia --exclude='*.conf' --exclude='server.crt' --exclude='server.key' --delete \ 32 time rsync --progress -pvia --exclude='*.conf' --exclude='server.crt' --exclude='server.key' --delete \
33{% if postgres_barman_rsync_enabled|default(false) -%}
31 --password-file=/var/lib/postgresql/.rsync_pass \ 34 --password-file=/var/lib/postgresql/.rsync_pass \
32 rsync://barman@{{ postgres_barman_server }}/backups/$BARMAN_DATABASE/base/$BARMAN_BACKUP_VERSION/data/ \ 35{%- endif %}
36 {% if postgres_barman_rsync_enabled|default(false) -%}rsync://{%- endif -%}barman@{{ postgres_barman_server }}{%- if postgres_barman_rsync_enabled|default(false) -%}/backups{%- else -%}:~{%- endif -%}/$BARMAN_DATABASE/base/$BARMAN_BACKUP_VERSION/data/ \
33 /var/lib/postgresql/{{ postgres_version }}/{{ postgres_cluster_name }}/ 37 /var/lib/postgresql/{{ postgres_version }}/{{ postgres_cluster_name }}/
34 38
35echo Restoring .conf and server certificate 39echo Restoring .conf and server certificate