@@ -412,7 +412,9 @@ if [ ! $FTP_BACKUP_OPTION -eq 0 ]; then
412412
413413 ftp -n -v $FTP_HOST $FTP_PORT < $TMP_DIR /backup.incoming/ftp_command.tmp
414414
415- echo " FTP Backup finish" | mail -s " $EMAIL_SUBJECT_TAG FTP backup finished !" $MAIL
415+ if [ -n " $MAIL " ]; then
416+ echo " FTP Backup finish" | mail -s " $EMAIL_SUBJECT_TAG FTP backup finished !" $MAIL
417+ fi
416418fi
417419
418420
@@ -421,7 +423,10 @@ if [ ! $LOCAL_BACKUP_OPTION -eq 0 ]; then
421423
422424 if [ ! -d $TARGET_DIR ]; then
423425 echo " Target directory : '$TARGET_DIR /' doesn't exist.."
424- echo " Target directory : '$TARGET_DIR /' doesn't exist.." | mail -s " $EMAIL_SUBJECT_TAG Failed !" $MAIL
426+ if [ -n " $MAIL " ]; then
427+ echo " Target directory : '$TARGET_DIR /' doesn't exist.." | mail -s " $EMAIL_SUBJECT_TAG Failed !" $MAIL
428+ fi
429+
425430 echo " Exiting..."
426431 exit
427432 fi
@@ -437,17 +442,25 @@ if [ -f $TARGET_DIR/$backup_filename ]; then
437442 RANDOM=$(( ( RANDOM % 100 ) + 1 ))
438443 # +Temp file to allow easy emailing of current list of backups.
439444 BACKUP_LIST=$TMP_DIR /backup.list.$RANDOM .txt
440- touch $BACKUP_LIST
441- echo " Sending mail"
442- echo " Local backup finished. Here's the current list of backups." > $BACKUP_LIST
443- echo " " >> $BACKUP_LIST
444- # +Sleep here to give the system a chance to catch up. If it goes to fast, the total size count could sometimes be incorrect.
445- sleep 2
446- ls -lah $TARGET_DIR >> $BACKUP_LIST
447- cat $BACKUP_LIST | mail -s " $EMAIL_SUBJECT_TAG Finished !" $MAIL
448- rm $TMP_DIR /backup.list.*
445+
446+ if [ -n " $MAIL " ]; then
447+ touch $BACKUP_LIST
448+ echo " Sending mail"
449+ echo " Local backup finished. Here's the current list of backups." > $BACKUP_LIST
450+ echo " " >> $BACKUP_LIST
451+ # +Sleep here to give the system a chance to catch up. If it goes to fast, the total size count could sometimes be incorrect.
452+ sleep 2
453+ ls -lah $TARGET_DIR >> $BACKUP_LIST
454+
455+ cat $BACKUP_LIST | mail -s " $EMAIL_SUBJECT_TAG Finished !" $MAIL
456+
457+ rm $TMP_DIR /backup.list.*
458+ fi
459+
449460else
450- echo " $TARGET_DIR /$backup_filename does not seem to exist. Something failed." | mail -s " $EMAIL_SUBJECT_TAG Finished, but failed." $MAIL
461+ if [ -n " $MAIL " ]; then
462+ echo " $TARGET_DIR /$backup_filename does not seem to exist. Something failed." | mail -s " $EMAIL_SUBJECT_TAG Finished, but failed." $MAIL
463+ fi
451464fi
452465
453466echo " Finish.."
0 commit comments