File tree Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Expand file tree Collapse file tree 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
3131
3232__postgresql_pgdg_bin_dir : " {{ '/usr/pgsql-' ~ (postgresql_version | replace('.', '')) ~ '/bin' }}"
3333postgresql_backup_command : >-
34- {{ postgresql_backup_local_dir | quote }}/bin/backup.py
34+ {{ postgresql_backup_python_executable }} {{ postgresql_backup_local_dir | quote }}/bin/backup.py
3535 {{ '--rsync-connect-opts ' ~ (postgresql_backup_rsync_connect_opts | quote) if postgresql_backup_rsync_connect_opts else '' }}
3636 --rsync-backup-opts {{ postgresql_backup_rsync_backup_opts | regex_replace('^-', '\-') | quote }}
3737 --keep {{ postgresql_backup_keep | quote }}
3838 {{ '--pg-bin-dir ' ~ __postgresql_pgdg_bin_dir if ansible_os_family == 'RedHat' else '' }}
3939 --backup --clean-archive {{ postgresql_backup_dir | quote }}
4040
41+ postgresql_backup_python_executable : " python"
42+
4143postgresql_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):
109109 def rsync_cmd (self ):
110110 cmd = ['rsync' ]
111111 if self ._rsync_opts :
112- cmd .extend (shlex .split (rsync_opts ))
112+ cmd .extend (shlex .split (self . _rsync_opts ))
113113 return cmd
114114
115115 @property
Original file line number Diff line number Diff line change @@ -13,10 +13,16 @@ wal_archive_dir={{ (postgresql_backup_dir ~ '/wal_archive') | quote }}
1313file_path=" $1 "
1414file_name=" $2 "
1515
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 %}
1621mkdir -p " $wal_archive_dir "
22+ {% endif %}
1723
1824# 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
2026 echo " ERROR: ${wal_archive_dir} /${file_name} already exists, overwriting is not allowed!"
2127 exit 1
2228fi
You can’t perform that action at this time.
0 commit comments