crontab postgres dump log enhanced

This commit is contained in:
Tommaso Piccioli 2017-11-29 12:39:18 +01:00
parent b4a9e1e582
commit e07f621b4c
1 changed files with 9 additions and 5 deletions

View File

@ -13,7 +13,8 @@ fi
# Remote backup performed by duplicity. When active, do not run via cron # Remote backup performed by duplicity. When active, do not run via cron
if [ -x /etc/cron.daily/duplicity_backup ] ; then if [ -x /etc/cron.daily/duplicity_backup ] ; then
echo "duplicity backups active. Exiting" > $LOG_FILE DATE=$( date )
echo "$DATE: duplicity backups active. Exiting" >> $LOG_FILE
exit 0 exit 0
fi fi
@ -23,7 +24,8 @@ if [ -f /var/log/backuppc.log ] ; then
. /var/log/backuppc.log . /var/log/backuppc.log
LAST_BACKUP_TIME=$( expr $TMSTMP - $BACKUP_TIMESTAMP ) LAST_BACKUP_TIME=$( expr $TMSTMP - $BACKUP_TIMESTAMP )
if [ $LAST_BACKUP_TIME -lt 86400 -a $BACKUP_RESULT == 'OK' ] ; then if [ $LAST_BACKUP_TIME -lt 86400 -a $BACKUP_RESULT == 'OK' ] ; then
echo "BackupPC is active, doing nothing" > $LOG_FILE DATE=$( date )
echo "$DATE: BackupPC is active, doing nothing" >> $LOG_FILE
exit 0 exit 0
fi fi
fi fi
@ -34,20 +36,22 @@ PG_RUNNING=$?
if [ $PG_BACKUP_ENABLED == 'True' ] ; then if [ $PG_BACKUP_ENABLED == 'True' ] ; then
if [ "$PG_RUNNING" -ne "0" -a "$PG_RUNNING" -ne "3" ] ; then if [ "$PG_RUNNING" -ne "0" -a "$PG_RUNNING" -ne "3" ] ; then
echo "The postgresql service is not running" > $LOG_FILE DATE=$( date )
echo "$DATE: The postgresql service is not running" >> $LOG_FILE
exit 1 exit 1
else else
if [ ! -d $LOG_DIR ] ; then if [ ! -d $LOG_DIR ] ; then
mkdir -p $LOG_DIR mkdir -p $LOG_DIR
fi fi
DATE_START=$( date ) DATE_START=$( date )
echo "$DATE_START: Starting the backup procedure" > $LOG_FILE echo "$DATE_START: Starting the backup procedure" >> $LOG_FILE
$PG_BCK_BIN >> $LOG_FILE 2>&1 $PG_BCK_BIN >> $LOG_FILE 2>&1
DATE_END=$( date ) DATE_END=$( date )
echo "$DATE_END: Backup procedure finished" >> $LOG_FILE echo "$DATE_END: Backup procedure finished" >> $LOG_FILE
fi fi
else else
echo "Postgresql backups administratively disabled" > $LOG_FILE DATE=$( date )
echo "$DATE: Postgresql backups administratively disabled" >> $LOG_FILE
fi fi
if [ "${USE_NAGIOS}" == "yes" ] ; then if [ "${USE_NAGIOS}" == "yes" ] ; then