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.

4
  • I would recommend BackupAssist for this type of scenario.
    – Skyhawk
    Jul 27, 2012 at 14:38
  • @Skyhawk <<We do not have a budget for third party solutions>> BackupAssist isn't free. Sep 3, 2015 at 23:31
  • @FlorianBidabe Check timestamps above.
    – Skyhawk
    Oct 5, 2015 at 4: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: blog.jocha.se/tech/wbadmin-backup-mail-reportenter image description here
    – user332412
    Jan 17, 2016 at 17:07

5 Answers 5

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.

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
1
  • You can test this script by filling the Backup_Error*.log with random data. May 22, 2017 at 21:49
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
  • Can you please post <<your script>> ? Sep 3, 2015 at 22:38
-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

1
  • 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. Sep 3, 2015 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

1
  • 1
    The question is about WBAdmin Sep 3, 2015 at 23:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .