2

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.

Greg
  • 23
  • 1
  • 3
  • I would recommend BackupAssist for this type of scenario. – Skyhawk Jul 27 '12 at 14:38
  • @Skyhawk <> BackupAssist isn't free. – Florian Bidabé Sep 03 '15 at 23:31
  • @FlorianBidabe Check timestamps above. – Skyhawk Oct 05 '15 at 04:54
  • Since email notifications through the scheduler is no longer supported (and was lacking to begin with), I've written a PowerShell script to review the logs and send a nice, easy to read, report. Check it out at: http://blog.jocha.se/tech/wbadmin-backup-mail-report[enter image description here](http://i.stack.imgur.com/ATYji.jpg) –  Jan 17 '16 at 17:07

5 Answers5

2

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.

joeqwerty
  • 108,377
  • 6
  • 80
  • 171
1

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 -body "Hello Administrator, Please consult the attached log" -attach %filename% -s "%computername% - Windows Server Backup has failed !" -to %Recipient%
exit 0
Florian Bidabé
  • 334
  • 2
  • 10
0

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.

-1

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

  • 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 Bidabé Sep 03 '15 at 23:28
-3

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

Ethabelle
  • 2,032
  • 14
  • 20