[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

anonftpsync mail subject



I have made a small change to my anonftpsync which I think could be useful to others,

[snip]
if [ 0 = $result ]; then
        # Now sync the remaining stuff
rsync --recursive --links --hard-links --times --verbose --delay-updates --delete-after \
             --exclude "Archive-Update-in-Progress-${HOSTNAME}" \
             --exclude "project/trace/${HOSTNAME}" \
             $TMP_EXCLUDE $EXCLUDE $SOURCE_EXCLUDE \
             $RSYNC_HOST::$RSYNC_DIR $TO >> $LOGFILE 2>&1

        LANG=C date -u > "${TO}/project/trace/${HOSTNAME}"
        MAIL_SUBJECT="debian archive sync successful"
else
        echo "ERROR: Help, something weird happened" | tee -a $LOGFILE
echo "mirroring /pool exited with exitcode" $result | tee -a $LOGFILE
        MAIL_SUBJECT="debian archive sync failed"
fi


if ! [ -z $MAILTO ]; then
        mail -s $MAIL_SUBJECT $MAILTO < $LOGFILE
fi
[/snip]

The subject line will tell you right away if the sync failed or not, and you won't need to scroll down to the end of the log every time.

However an improvement, if the second pass failes, the subject line will still say it's a success. A second "result=$?" and an if statement just before the mail is sent may solve this case.

Ricardo



Reply to: