From f972e46012db43964ebcecddad216254bc9d0981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20S=C3=89RIE?= Date: Wed, 5 Feb 2014 16:04:52 +0100 Subject: [PATCH] Send mail report only if incrementals where deleted. --- crons/evobackup-rm.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/crons/evobackup-rm.sh b/crons/evobackup-rm.sh index 4c66cff..47c7f37 100644 --- a/crons/evobackup-rm.sh +++ b/crons/evobackup-rm.sh @@ -31,15 +31,17 @@ for client in ${CONFDIR}/*; do echo "Deletion of ${backupname}/${inc#${INCDIR}/${backupname}/} started at ${start}." >> $tmplog # We use rsync to delete since it is faster than rm! rsync -a --delete ${emptydir}/ $inc - rm -r $inc + rmdir $inc stop=$(date --rfc-3339=seconds) echo "Deletion of ${backupname}/${inc#${INCDIR}/${backupname}/} ended at ${stop}." >> $tmplog done done -# Save tmplog to global log. -cat $tmplog >> $LOGFILE -# Send mail report. -< $tmplog mailx -s "[info] EvoBackup - deletion of obsolete incrementals" $MAIL_TO + +# Send mail report only if incrementals where deleted. +if [ -s $tmplog ]; then + # Save tmplog to global log & send mail. + cat $tmplog >> $LOGFILE + < $tmplog mailx -s "[info] EvoBackup - deletion of obsolete incrementals" $MAIL_TO +fi # Cleaning -rm -rf $tmpdir $emptydir -rm $tmplog \ No newline at end of file +rm -rf $tmpdir $emptydir $tmplog \ No newline at end of file