library/roles/postgresql: Scripts to regularly cleanup the WAL archives.

This commit is contained in:
Andrea Dell'Amico 2016-04-08 19:24:35 +02:00
parent 8362be052b
commit 552cce1dc4
2 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,17 @@
#!/bin/bash
BASE_BACKUP_DIR=/var/lib/pgsql/base_backup
WAL_ARCHIVES_LOG_DIR=/var/lib/postgresql/9.5/archive_log
WAL_LATEST_BACKUP=
# The base backup dir needs to be empty
rm -f $BASE_BACKUP_DIR/*
pg_basebackup -F t -z -D /var/lib/pgsql/base_backup
cd $WAL_ARCHIVES_LOG_DIR
WAL_LATEST_BACKUP=$( /bin/ls -1 *.backup | sort | tail -1 )
pg_archivecleanup $WAL_ARCHIVES_LOG_DIR $WAL_LATEST_BACKUP
exit $?

View File

@ -0,0 +1,6 @@
#!/bin/bash
su - postgres -c "/usr/local/sbin/postgresql_wal_backup_and_removal > /var/log/postgresql/wal_removal.log 2>&1"
exit 0