Sébastien Arpin
2009-Dec-30 00:12 UTC
rsync email notification on success and failure + Log
Hi, I have a bash script for rsync that should tranfer all my filer from one drive to the other. I would like to know how I can make the script sending me an email after the script is run and be able to know if it was a success or not and also if possible to include the log file. This is my script: !/bin/bash rsync -av --delete --log-file=/home/duffed/RSyncLog/$(date +%Y%m%d)_rsync_Multimedia.log /media/Multimedia/ /media/MultimediaBackUp Thanks a lot! S?bastien -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.samba.org/pipermail/rsync/attachments/20091230/8f0c5a33/attachment.html>
Eberhard Moenkeberg
2009-Dec-30 00:29 UTC
rsync email notification on success and failure + Log
Hi, On Wed, 30 Dec 2009, S?bastien Arpin wrote:> I have a bash script for rsync that should tranfer all my filer from one > drive to the other. > > I would like to know how I can make the script sending me an email after > the script is run and be able to know if it was a success or not and > also if possible to include the log file.I do it this way: rsync ${ALLOPTS} ${SRC} ${DST} >>${PROT} 2>&1 RC=$? DAT2="`date +%y%m%d.%H%M`" if test "${RC}" = "0" -o "${RC}" = "23"; then grep "^Total file size: " ${PROT} | \ ( read a b c d e echo "${DAT2} ${NAM} size: $d bytes." >>${DST}/.gwdg-mirror ) else touch ${DST}/.gwdg-mirror fi echo "==== end ======== RC=${RC} ============ ${DAT1} ${DAT2}" >>${PROT} MAILIT=yes if [ "${RC}" = "0" ]; then NUMFIL=`grep "^Number of files transferred:" ${PROT} | \ (while read n o f t X; do echo -n ${X}; done)` if [ "${NUMFIL}" = "0" ]; then MAILIT=no fi fi if [ "${MAILIT}" = "yes" ]; then V1="is uptodate" V2="is a hard link" V3="^backed up " V4="^deleting " grep -v "${V1}\|${V2}\|${V3}\|${V4}" ${PROT} | \ mail -s"${SUBJ} (RC=${RC})" ${MAILTO} #else # mail -s"${SUBJ} (RC=${RC}) __nomail__" ${MAILTO} <${PROT} fi Viele Gruesse Eberhard Moenkeberg (emoenke at gwdg.de, em at kki.org) -- Eberhard Moenkeberg Arbeitsgruppe IT-Infrastruktur E-Mail: emoenke at gwdg.de Tel.: +49 (0)551 201-1551 ------------------------------------------------------------------------- Gesellschaft fuer wissenschaftliche Datenverarbeitung mbH Goettingen (GWDG) Am Fassberg 11, 37077 Goettingen URL: http://www.gwdg.de E-Mail: gwdg at gwdg.de Tel.: +49 (0)551 201-1510 Fax: +49 (0)551 201-2150 Geschaeftsfuehrer: Prof. Dr. Bernhard Neumair Aufsichtsratsvorsitzender: Dipl.-Kfm. Markus Hoppe Sitz der Gesellschaft: Goettingen Registergericht: Goettingen Handelsregister-Nr. B 598 -------------------------------------------------------------------------
Hi: Let cron(8) run your script for you. Cron will happily email you the verbose output from rsync after its task has run. man cron man crontab man 5 crontab On Tue, Dec 29, 2009 at 7:12 PM, S?bastien Arpin <sebarpin at hotmail.com> wrote:> Hi, > > I have a bash script for rsync that should tranfer all my filer from one > drive to the other. > > I would like to know how I can make the script sending me an email after the > script is run and be able to know if it was a success or not and also if > possible to include the log file. > > This is my script: > > !/bin/bash > > rsync -av --delete --log-file=/home/duffed/RSyncLog/$(date > +%Y%m%d)_rsync_Multimedia.log /media/Multimedia/ /media/MultimediaBackUp > > > Thanks a lot! > > S?bastien > > > > > > > > -- > Please use reply-all for most replies to avoid omitting the mailing list. > To unsubscribe or change options: > https://lists.samba.org/mailman/listinfo/rsync > Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html >-- W. Oates
> I have a bash script for rsync that should tranfer all my filer from one drive to the other. > > I would like to know how I can make the script sending me an email after the script is run and be able to know if it was a success or not and also if possible to include the log file.You may want to have a look at LBackup. The latest alpha release includes support for backup specific mail templates. If you want to use your backup script, rather than LBackup; you could use the lmail command to manage email delivery of your backup reports. If you are interested in rolling your own email delivery system then the source code for lmail may be helpful and is available from : http://www.lbackup.org/source