aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/standby-clone.sh.j2
diff options
context:
space:
mode:
authorThéophile Helleboid - chtitux <chtitux@gmail.com>2019-01-02 14:23:36 +0100
committerGitHub <noreply@github.com>2019-01-02 14:23:36 +0100
commit758d478b83050f248f5df8177027e2870f4308c5 (patch)
treeec16b304ef816d5ab65fd4217bbb8748ffad94fe /templates/standby-clone.sh.j2
parent8371771c8e9b8a2f2a6a4d81a142ddc805e198b4 (diff)
parentc95984df57136048002f0d60c6469d9bbbdd1e0a (diff)
downloadansible-postgresql-role-758d478b83050f248f5df8177027e2870f4308c5.tar.gz
ansible-postgresql-role-758d478b83050f248f5df8177027e2870f4308c5.tar.zst
ansible-postgresql-role-758d478b83050f248f5df8177027e2870f4308c5.zip
Merge pull request #3 from paulRbr/barman-rsync-optional1.2.0
standby: rsync from barman is optional if SSH access is already here
Diffstat (limited to 'templates/standby-clone.sh.j2')
-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