Skip to content

Commit dc162fb

Browse files
Properly handle WAL directory in backup scripts for PostgreSQL version >=10
1 parent 313e33c commit dc162fb

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

templates/backup_working_wal.sh.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## This file is maintained by Ansible - CHANGES WILL BE OVERWRITTEN
44
##
55

6-
xlog_dir='{{ postgresql_pgdata }}/pg_xlog'
6+
xlog_dir='{{ postgresql_pgdata~"/"~postgresql_version is version_compare("10", ">=") | ternary("pg_wal", "pg_xlog") }}'
77
backup_dir={{ postgresql_backup_active_dir }}
88
mailto='{{ postgresql_backup_mail_recipient }}'
99

templates/scheduled_backup.sh.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ dir='{{ postgresql_backup_dir }}/current'
99
mailto='{{ postgresql_backup_mail_recipient }}'
1010
mutex={{ postgresql_backup_local_dir }}/scheduledmutex
1111
rotate='{{ postgresql_backup_rotate | default("True") }}'
12+
xlog_dir='{{ postgresql_version is version_compare("10", ">=") | ternary("pg_wal", "pg_xlog") }}'
1213

1314
[ '{{ postgresql_backup_remote_rsync_path | default("None") }}' != 'None' ] && remote_rsync='--rsync-path={{ postgresql_backup_remote_rsync_path | default("None") }}' || remote_rsync=''
1415

@@ -83,7 +84,7 @@ backup_started=1
8384
handler mkdir -p $data/wal
8485

8586
# begin the backup
86-
handler rsync $remote_rsync -rptg --delete --delete-delay --exclude pg_xlog $data/ $dir
87+
handler rsync $remote_rsync -rptg --delete --delete-delay --exclude $xlog_dir $data/ $dir
8788

8889
# tell postgres we're done
8990
psql_handler "SELECT pg_stop_backup();"

0 commit comments

Comments
 (0)