We help IT Professionals succeed at work.

Incorporating SMTP Alert to Backup Script

our backups are batch files that use robocopy.  the batch file is called by scheduled tasks.

is there a way to have an alert sent via SMTP if a backup fails?  i'm guessing it would need to read the log file produced by robocopy, and then send an alert if a certain phrase is found.  or perhaps there is something that integrates more closely with robocopy???

my purpose is that i'd like to get an email alert if a backup fails.
Watch Question

Technology and Business Process Advisor
Most Valuable Expert 2013
Hmmm... do you use Exchange?

How do you backup your system state data?

If Robocopy is your only backup, I might be concerned depending on your answers to these questions.

That said, you need a command line e-mail program (BLAT for example) and to include a section in the script.  Doing it the way you appear to want it done (not necessarily how I'd do it though), would require a section that would, for example, do this:

find /i "keyword or phrase in" yourrobocopy.log
if "%errorlevel%" == "0" blat <insert blat command line options here
Top Expert 2010


we do not use Exchange.
as of this point, there is no backup of system state (i am the only IT person and i know it needs to be done, but haven't had time to do it yet... i do everything under the sun, including database management, report writing, etc... and so i have pointed out to the Partners that i need time to do other important tasks... hopefully soon!).
at this point, it is only data backup.

i can see where you are going with the command line email program... that helps.  thanks
Lee W, MVPTechnology and Business Process Advisor
Most Valuable Expert 2013

Backing up the system state is not difficult... Frankly, except for a few critical files as a SECONDARY backup, I would do a copy (ROBOCOPY/COPY/XCOPY/SCOPY/XXCOPY) as my backups.  The built in backup tool to Windows is scriptable and can backup your data and system state to a file.  To that end, if you'd like to experiment, I have a script written for this that you can try.  You just need to define the jobs and store them in the appropriate folder.

If you want to have a look, check out the links section of my backup page (and you might want to review that as well):