script to start basebackup and wal clean up fto backuppc

This commit is contained in:
Tommaso Piccioli 2021-09-21 17:18:09 +02:00
parent 62059a65f3
commit 7651e5cc48
3 changed files with 17 additions and 0 deletions

4
files/backuppc_pg_wal.sh Executable file
View File

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

View File

@ -117,6 +117,11 @@
- name: Install a script that cleans up the wal log archives
template: src=postgresql_wal_backup_and_removal.j2 dest=/usr/local/sbin/postgresql_wal_backup_and_removal owner=root group=root mode=0755
tags: [ 'postgres', 'postgresql', 'sudo', 'pgpool' ]
- name: backuppc root script to syncronize backup and wal clean up
copy: src=backuppc_pg_wal.sh dest=/usr/local/sbin/backuppc_pg_wal.sh owner=root mode=0744
tags: [ 'postgres_backuppc', 'postgres', 'postgresql', 'pgpool' ]
# The script is started by the backup server after the file copy, crontab action must be deleted
#- name: Install a cron job to cleanup the wal log archives

8
templates/postgresql_wal_backup_and_removal.j2 Normal file → Executable file
View File

@ -1,5 +1,12 @@
#!/bin/bash
ISMASTER=`psql -t -c "SELECT pg_is_in_recovery();"`
if [ $ISMASTER != 'f' ]
then
echo "Not on master, nothing to do."
exit 0
fi
BASE_BACKUP_DIR={{ psql_base_backup_dir }}
WAL_ARCHIVES_LOG_DIR={{ psql_wal_archiving_log_dir }}
WAL_LATEST_BACKUP=
@ -15,3 +22,4 @@ pg_archivecleanup $WAL_ARCHIVES_LOG_DIR $WAL_LATEST_BACKUP
exit $?