Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Does anyone have a script they use with WBADMIN to send email alerts? I am a scripting newbie and having trouble finding a solution to notify on failed backups. Seems like it would be a useful tool to have.

I am running Server 2008 R2 Foundation and backing up to a NAS. I am using wbadmin with task scheduler to perform daily backups.

UPDATE We do not have a budget for third party solutions so I am trying to effect a solution through a simple script.

share|improve this question
    
I would recommend BackupAssist for this type of scenario. –  Skyhawk Jul 27 '12 at 14:38
    
@Skyhawk <<We do not have a budget for third party solutions>> BackupAssist isn't free. –  Florian Bidabe 4 hours ago

5 Answers 5

If you've already had a failed backup it should be easy enough to accomplish by finding the failed backup in the Backup|Operational event log, right-clicking the failed event, selecting "Attach Task to this Event", and filling out the task settings appropriately.

Then whenever a backup fails and logs the event to the log, an email will be sent based on your task configuration.

share|improve this answer

you can use blat which is a command line tool that sends an email using an SMTP server and credentials you specify. I have set up my script to use blat and send me an email on the failure of wbadmin backup.

It's an incredibly useful tool for scripting. I use it all the time in alot of my scripts to alert me of status that may require my attention.

share|improve this answer
    
Can you please post <<your script>> ? –  Florian Bidabe 5 hours ago

On Server 2012, The backup tool writes two log files after each backup task: enter image description here

  • When successfull,Backup_Error-<date>.log is created but empty.
  • When unsuccessful, I assume that a Backup_Error-<date>.log would be populated with data.

    Using task scheduler, I run a batch file to achieve the following:

    1. Delete empty .log files in C:\Windows\Logs\WindowsServerBackup directory
    2. Search for (remaining) Backup_Error*.log (because non-empty)
    3. Mail its content to me using Blat
@echo off
:: This script has been written to monitor WBAdmin backups on Server 2012
::
:: Tested on: Microsoft Windows Server 2012 Standard (6.2.9200 N/A Build 9200) 
:: Date:      September 4, 2015
:: Author Florian Bidabe @Enelass (https://au.linkedin.com/in/bidabe)

::Variables
set MailServer=
set Sender=
set Recipient=


:: Delete Empty files
cd C:\Windows\Logs\WindowsServerBackup
for %%F in (*) do if %%~zF equ 2 del "%%F"

:: Look for Backup_Error file(s)
dir C:\Windows\Logs\WindowsServerBackup\Backup_Error*.log  > nul 2> nul
if %ERRORLEVEL% EQU 0 goto :AdminAlert
echo No Error Logs available ! Backup suceeded !
ping 0.0.0.0 -n 5 > nul 2> nul
exit 0

:AdminAlert
:: Test if blat can be found (SMTP Server)
where blat > nul 2> nul
if not %ERRORLEVEL% EQU 0 (
 echo Blat cannot be found... Copy blat.exe in system32!
 ping 0.0.0.0 -n 5 > nul 2> nul
 exit 1)

:: Select most recent error log
FOR %%F IN (C:\Windows\Logs\WindowsServerBackup\Backup_Error*.log) DO (
 set filename=%%F
 goto :Send
)

:Send
blat -SaveSettings -f %Sender% -server %MailServer%
::blat %filename% -to AU-ServerAlerts@yum.com
blat -body "Hello Administrator, Please consult the attached log" -attach %filename% -s "%computername% - Windows Server Backup has failed !" -to %Recipient%
exit 0
share|improve this answer

You don't have to script this unless you just really want to. Webmin can do this ... if you are using Webmin's backup, when you go to "Schedule a Backup" > Create Schedule > Backup Schedule there is an option there allows you to notify someone by e-mail if an error occurs.

Webmin Backup

share|improve this answer
    
The question is about WBAdmin –  Florian Bidabe 4 hours ago

MKSBackup is what you are looking for.

You don't even need to script anything, just fill in the .ini file with what and where to backup. Add your email address and you get a very complete but simple mail report.

MKSBackup even create the task in the Task scheduler for you at installation.

MKSBackup is released under GPL at http://www.magikmon.com/mksbackup

share|improve this answer
    
I followed the instructions on the site, enter all parameters in the ini and got a "ERR job not found: PRINTSRVBCK" every time I run the scheduled task. MKSBackup was last update in Januray 2013. –  Florian Bidabe 4 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.