2016-04-08 19:24:35 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-06-07 18:26:14 +02:00
|
|
|
BASE_BACKUP_DIR={{ psql_base_backup_dir }}
|
|
|
|
WAL_ARCHIVES_LOG_DIR={{ psql_wal_archiving_log_dir }}
|
2016-04-08 19:24:35 +02:00
|
|
|
WAL_LATEST_BACKUP=
|
|
|
|
|
|
|
|
# The base backup dir needs to be empty
|
|
|
|
|
|
|
|
rm -f $BASE_BACKUP_DIR/*
|
2016-06-07 18:26:14 +02:00
|
|
|
pg_basebackup -F t -z -D $BASE_BACKUP_DIR
|
2016-04-08 19:24:35 +02:00
|
|
|
|
|
|
|
cd $WAL_ARCHIVES_LOG_DIR
|
2016-06-07 18:26:14 +02:00
|
|
|
WAL_LATEST_BACKUP=$( /bin/ls -1tr *.backup | tail -1 )
|
2016-04-08 19:24:35 +02:00
|
|
|
pg_archivecleanup $WAL_ARCHIVES_LOG_DIR $WAL_LATEST_BACKUP
|
|
|
|
|
|
|
|
exit $?
|
|
|
|
|