forked from ISTI-ansible-roles/ansible-roles
library/roles/postgresql: Scripts to regularly cleanup the WAL archives.
This commit is contained in:
parent
8362be052b
commit
552cce1dc4
|
@ -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 $?
|
||||
|
|
@ -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
|
||||
|
Loading…
Reference in New Issue