diff options
author | Théophile Helleboid - chtitux <chtitux@gmail.com> | 2019-01-02 14:23:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-02 14:23:36 +0100 |
commit | 758d478b83050f248f5df8177027e2870f4308c5 (patch) | |
tree | ec16b304ef816d5ab65fd4217bbb8748ffad94fe /templates | |
parent | 8371771c8e9b8a2f2a6a4d81a142ddc805e198b4 (diff) | |
parent | c95984df57136048002f0d60c6469d9bbbdd1e0a (diff) | |
download | ansible-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')
-rwxr-xr-x | templates/standby-clone.sh.j2 | 8 |
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 | ||
4 | set -eo pipefail | ||
5 | |||
4 | BARMAN_DATABASE=$1 | 6 | BARMAN_DATABASE=$1 |
5 | BARMAN_BACKUP_VERSION=$2 | 7 | BARMAN_BACKUP_VERSION=$2 |
6 | 8 | ||
@@ -17,7 +19,7 @@ echo "accept key if necessary" | |||
17 | sudo -u postgres ssh barman@{{ postgres_barman_server }} echo "" | 19 | sudo -u postgres ssh barman@{{ postgres_barman_server }} echo "" |
18 | 20 | ||
19 | echo Stopping PostgreSQL | 21 | echo Stopping PostgreSQL |
20 | pg_ctlcluster {{ postgres_version }} {{ postgres_cluster_name }} stop | 22 | pg_ctlcluster {{ postgres_version }} {{ postgres_cluster_name }} stop || true |
21 | 23 | ||
22 | echo Cleaning up old cluster directory | 24 | echo Cleaning up old cluster directory |
23 | sudo -u postgres mv /var/lib/postgresql/{{ postgres_version }}/{{ postgres_cluster_name }}{,_$BACKUP_DATE} | 25 | sudo -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 | |||
28 | echo Get previous backup from backups server | 30 | echo Get previous backup from backups server |
29 | sudo -u postgres \ | 31 | sudo -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 | ||
35 | echo Restoring .conf and server certificate | 39 | echo Restoring .conf and server certificate |