From bdcf69b0e6f3286ade0b726916ff76c475646baf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Fri, 30 Nov 2018 18:12:23 +0200 Subject: [PATCH] Keep one more WAL archive, to enable single-last backup recovery --- optional/postgresql/basebackup.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/optional/postgresql/basebackup.sh b/optional/postgresql/basebackup.sh index 14e3f804..907da2ef 100755 --- a/optional/postgresql/basebackup.sh +++ b/optional/postgresql/basebackup.sh @@ -17,14 +17,12 @@ done # Clean the wall archive cd /backup/wal_archive || exit $? if [ $(ls *.*.backup | wc -l) -lt 2 ]; then - ls /backup/wal_archive exit 0 fi # Find the single last wal.backup point -prev_wal_start="$(ls *.*.backup | tail -n2 | head -n1)" +prev_wal_start="$(ls *.*.backup | tail -n2 | head -n1 | cut -d '.' -f 1)" for f in $(ls) ; do - if [ "$f" \< "$prev_wal_start" ] || [ "$f" \= "$prev_wal_start" ]; then + if [ "$f" \< "$prev_wal_start" ]; then rm -v /backup/wal_archive/$f fi done -ls /backup/wal_archive