[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,

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}" \
             $RSYNC_HOST::$RSYNC_DIR $TO >> $LOGFILE 2>&1

        LANG=C date -u > "${TO}/project/trace/${HOSTNAME}"
        MAIL_SUBJECT="debian archive sync successful"
        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"

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

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.


Reply to: