2015-05-28 11:32:57 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [ -f /etc/default/pg_backup ] ; then
|
|
|
|
. /etc/default/pg_backup
|
|
|
|
else
|
2016-01-11 17:43:50 +01:00
|
|
|
PG_BACKUP_ENABLED=True
|
2015-05-28 11:32:57 +02:00
|
|
|
PG_SERVICE=postgresql
|
|
|
|
USE_NAGIOS=no
|
|
|
|
LOG_DIR=/var/log/postgresql
|
|
|
|
LOG_FILE=$LOG_DIR/postgresql-backup.log
|
|
|
|
PG_BCK_BIN=/usr/local/sbin/postgresql-backup
|
|
|
|
fi
|
|
|
|
|
|
|
|
export PATH="/sbin:/usr/sbin:/usr/local/sbin:$PATH"
|
|
|
|
PG_SVC=$( service $PG_SERVICE status >/dev/null )
|
|
|
|
PG_RUNNING=$?
|
|
|
|
|
2016-01-11 17:43:50 +01:00
|
|
|
if [ '$PG_BACKUP_ENABLED' == 'True' ] ; then
|
|
|
|
if [ "$PG_RUNNING" -ne "0" -a "$PG_RUNNING" -ne "3" ] ; then
|
|
|
|
echo "The postgresql service is not running" > $LOG_FILE
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
if [ ! -d $LOG_DIR ] ; then
|
|
|
|
mkdir -p $LOG_DIR
|
|
|
|
fi
|
|
|
|
$PG_BCK_BIN > $LOG_FILE 2>&1
|
|
|
|
fi
|
2015-05-28 11:32:57 +02:00
|
|
|
else
|
2016-01-11 17:43:50 +01:00
|
|
|
echo "Postgresql backups administratively disabled" > $LOG_FILE
|
2015-05-28 11:32:57 +02:00
|
|
|
fi
|
2016-01-11 17:43:50 +01:00
|
|
|
|
2015-05-28 11:32:57 +02:00
|
|
|
if [ "${USE_NAGIOS}" == "yes" ] ; then
|
|
|
|
N_LOGDIR=/var/log/nagios-checks
|
|
|
|
if [ ! -d $N_LOGDIR ] ; then
|
|
|
|
mkdir -p $N_LOGDIR
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|
|
|
|
|