February 22, 2010

Notification: WSB Can Do Notifications

I had a client who, much to my dismay, purchased a new server from Dell and opted not to go with Backup Exec but rather the free Yosemite Backup application that ships with the RD1000 drives. Not a huge deal until I discovered after a good deal of troubleshooting that Yosemite does not work with Server 2008 R2. Long story short, we were left with no option but to use Windows Server Backup and find a way to configure e-mail notifications.


According to Microsoft and the forums I looked at (including Expert's Exchange), the only information I found was either a big fat "not supported" or some convoluted and surely unreliable scripted solution. Several folks were on the right track with using Task Scheduler. However, everyone I spoke with lamented that WSB does not appear to log anything useful in the System or Application logs except this event:


Which tells us nothing except that the backup may be starting and is not at all useful to us. Take a look in the Applications and Services Logs > Microsoft > Windows > Backup > Operational log and we find something much more suitable:


So now that we see where our event logs appear for WSB, we can use Task Scheduler to create some email alerts. First, you'll need a few prerequisites on the server:
  1. Windows Server Backup obviously has to be installed. Unlike NTBackup in 2003, it is not included in the default installation in Server 2008.
  2. Simple Mail Transport Protocol will be needed if you don't already have an SMTP server you can relay off of (such as an ISP server). You will need to configure it to allow relaying from your WSB server with no authentication. WSB is not capable of authenticating in any way to an SMTP server.
  3. IIS 7.0 needs to be up and running to house your SMTP virtual server.
  4. IIS 6.0 Manager also needs to be installed to manage the legacy SMTP stuff.


To get started, open up Server Manager and drill down to Configuration > Task Scheduler > Task Scheduler Library > Event Viewer Tasks.




1. Select Create Task... from the task pane.


Enter a name and description for your new task. Be sure to select the option to "Run whether user is logged on or not" to ensure the task still runs after you log out. 



2. Click on the Triggers tab and click on New.



Select "On an Event" from the drop down. Hit Custom and then open a "New Event Filter..."



3. Select all of the event levels (realistically, failures should only ever use Critical, Error, or Warning, but why take the chance?). Select "By log" and choose the Microsoft-Windows-Backup/Operational log to monitor.


Enter all of the event ID's for WSB errors and warnings and then click OK. What, you don't know these? Luckily TechNet lists them for us. Here is the string you can input for the the ID's:

5,8,9,17-22,49,50,52,100,517,518,521,527,528,544,545,546,561,564,612

You could also use Keywords such as "fail" and "warning", but this just seems cleaner and more reliable to me.



4. Head over to the Actions tab and select "New...". Most of this should be self-explanatory:


I'm sure you could script some way of exporting the logs and attaching them, but this should be enough for a simple e-mail notification just to say "Hey, go look at the server cause your backup failed". If you are using another server to relay SMTP messages, enter its IP address in the SMTP Server field. You can also specify more than one recipient by either using a distribution group or separating the email addresses with a comma.



5. If you want to test your email notifications, be sure to check the "Allow task to be run on demand" option under the Settings tab.



That's it for failure notifications! I also recommend you repeat these steps for success notifications (just change the events to event ID 4 on step 3). That way if the server just drops off the network completely or has another issue preventing it from sending mail, the lack of email message will help indicate a problem. Be sure to schedule a "backup failure test" using a bad target of some sort to double-check that your failure messages trigger appropriately.


14 comments:

  1. HUGE Help, thanks!

    ReplyDelete
  2. Nice!

    But how will you ever hear from this server that this task/backup-job not run anymore? "No error mailed" <> "Job done, everything ok"

    What do you think about a trigger for the EventID 4 in combination with "last entry not older then 24 hours"?

    ReplyDelete
  3. Yes, you are correct. That's what I'm alluding to in the final paragraph. No error message does not equal no error.

    I think your idea for a "last entry not older than 24 hours" (or whatever your backup schedule is) would be a great idea. Our managed service software can do this easily, but that is involving third party utilities.

    ReplyDelete
  4. Is there any way I can get my client's GoDaddy POP account to relay the messages?

    ReplyDelete
  5. Hi There. Thanks paul for this great tutorial. I was wondering if anyone had documented how to add the 'not older than' idea? I can't see how to set this up. Thanks, Mark.

    ReplyDelete
  6. Very very nice tutorial.
    I just want to mention, the user that runs the task needs to be a member of Domain Admins group in Active Directory to have permission to send the e-mail.
    Also, for some reasons when i set the task up on my SMTP server, I had to check the box "Run with highest privileges", otherwise it fails with error value: 2147746321

    ReplyDelete
  7. Superb! Up and runnig in 2min. Thank you!

    ReplyDelete
  8. OMGWTFBBQ - Hilarious! ASN many thanks for a superb article!

    ReplyDelete
  9. Great article!
    Two problems for me.
    Windows8/Server 2012

    Server2012 when creating the task error : 2147750704

    Anybody who has fix for this?

    Thx

    ReplyDelete
  10. In Windows 8 / Server 2012, the "Send e-mail" function of Scheduled Tasks has been deprecated unfortunately. You can get around this by using a PowerShell script. This site walks you through the process (along with a few other alternatives):

    http://www.askvg.com/fix-cant-create-tasks-to-display-messages-in-windows-8-task-scheduler/

    ReplyDelete
  11. In response to Kenneth's comment about GoDaddy POP:

    Unfortunately not, to the best of my knowledge. The action screen for scheduling this task does not allow you to specify any authentication methods or alternative ports, and GoDaddy will probably require both in order to relay off of them.

    As per my previous comment, you can use a PowerShell Script to send the e-mail instead and probably specify this information:


    http://www.askvg.com/fix-cant-create-tasks-to-display-messages-in-windows-8-task-scheduler/

    ReplyDelete
  12. Thanks for this.. it was a great help

    ReplyDelete