File tree 3 files changed +11
-3
lines changed
3 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -31,11 +31,13 @@ postgresql_backup_keep: 30
31
31
32
32
__postgresql_pgdg_bin_dir : " {{ '/usr/pgsql-' ~ (postgresql_version | replace('.', '')) ~ '/bin' }}"
33
33
postgresql_backup_command : >-
34
- {{ postgresql_backup_local_dir | quote }}/bin/backup.py
34
+ {{ postgresql_backup_python_executable }} {{ postgresql_backup_local_dir | quote }}/bin/backup.py
35
35
{{ '--rsync-connect-opts ' ~ (postgresql_backup_rsync_connect_opts | quote) if postgresql_backup_rsync_connect_opts else '' }}
36
36
--rsync-backup-opts {{ postgresql_backup_rsync_backup_opts | regex_replace('^-', '\-') | quote }}
37
37
--keep {{ postgresql_backup_keep | quote }}
38
38
{{ '--pg-bin-dir ' ~ __postgresql_pgdg_bin_dir if ansible_os_family == 'RedHat' else '' }}
39
39
--backup --clean-archive {{ postgresql_backup_dir | quote }}
40
40
41
+ postgresql_backup_python_executable : " python"
42
+
41
43
postgresql_default_auth_method : " {{ (postgresql_version is version('13', '>')) | ternary('scram-sha-256', 'md5') }}"
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ def pg_major_version(self):
109
109
def rsync_cmd (self ):
110
110
cmd = ['rsync' ]
111
111
if self ._rsync_opts :
112
- cmd .extend (shlex .split (rsync_opts ))
112
+ cmd .extend (shlex .split (self . _rsync_opts ))
113
113
return cmd
114
114
115
115
@property
Original file line number Diff line number Diff line change @@ -13,10 +13,16 @@ wal_archive_dir={{ (postgresql_backup_dir ~ '/wal_archive') | quote }}
13
13
file_path=" $1 "
14
14
file_name=" $2 "
15
15
16
+ {% if " :" in postgresql_backup_dir %}
17
+ empty=$( mktemp -d -t ansible-postgresql-empty.XXXXXX)
18
+ rsync {{ postgresql_backup_rsync_connect_opts }} " ${empty} /" " $wal_archive_dir "
19
+ rmdir " $empty "
20
+ {% else %}
16
21
mkdir -p " $wal_archive_dir "
22
+ {% endif %}
17
23
18
24
# If rsync outputs anything to stdout, the destination already existed, which should not happen
19
- if [ -n " $( rsync {{ postgresql_archive_wal_rsync_args }} " $file_path " " $wal_archive_dir " ) " ]; then
25
+ if [ -n " $( rsync {{ postgresql_backup_rsync_connect_opts }} {{ postgresql_archive_wal_rsync_args }} " $file_path " " $wal_archive_dir " ) " ]; then
20
26
echo " ERROR: ${wal_archive_dir} /${file_name} already exists, overwriting is not allowed!"
21
27
exit 1
22
28
fi
You can’t perform that action at this time.
0 commit comments