none
Email notification for Windows Server 2012 Windows Backup

    Question

  • How to configure a email notification for "successful/failure" Windows Server Backup Scheduled Task on Windows Server 2012 Standard Edition?
    Tuesday, May 28, 2013 9:20 PM

Answers

  • OK. It's not terribly difficult, just a few batch files.

    Here's a step-by-step using blat. Items in greater than/less than symbols (e.g. <ServerIP>) need to be changed to suit your environment.


    1. Download blat (www.blat.net or blat.sourceforge.net)
    2. Install blat. Extract the archive and copy the files in the Full directory in the archive to a directory (if multiple applications are using it you might want to put it somewhere in the PATH, like %window%\system32)
    3. Configure blat. Basically this means setting the IP address of the receiving mail server and a FROM email address (mail sent by blat will appear sent by the email address you set here):
          blat -install <MailServerIP> <FROMEmailAddress>

          As an example, if your mail server address is 192.168.0.10 and the email address you want the emails to use is WSB-Server@backup.local:
              blat -install 192.168.0.10 WSB-Server@backup.local
    4. Create a new directory in Program Files called EmailNotification
    5. Create a few text files in the EmailNotification directory (these will be the bodies of the emails sent on notification):
          File: BackupFailure.txt
          Contents: WSB (<ServerRunningWSB>): The backup failed.

          File: BackupStart.txt
          Contents: WSB (<ServerRunningWSB>): The backup has started.

          File: BackupSuccess.txt
          Contents: WSB (<ServerRunningWSB>): The backup completed successfully.
    6. Create a few batch files in the EmailNotification directory to actually send the emails:
          File: BackupFailure.bat
          Contents: @blat "C:\Program Files\EmailNotification\BackupFailure.txt" -to <DestinationEmailAddress> -subject "WSB (<ServerRunningWSB>): Backup failed."

          File: BackupStart.bat
          Contents: @blat "C:\Program Files\EmailNotification\BackupStart.txt" -to <DestinationEmailAddress> -subject "WSB (<ServerRunningWSB>): Backup started."


          File: BackupSuccess.bat
          Contents: @blat "C:\Program Files\EmailNotification\BackupSuccess.txt" -to <DestinationEmailAddress> -subject "WSB (<ServerRunningWSB>): Backup completed successfully."
    7. Now test them to see if they send email, open a command prompt, change to the "C:\Program Files\EmailNotification" directory and run each batch file manually to make sure mail is getting through. It's important to run this in the command prompt as it echoes what it's doing, so if they're problems it'll tell you. If you have problems getting the emails through you need to fix it at this step. Firewalls or SMTP rules may need to be created to allow the emails through.


    The installation and configuration of the scripts is now done. Now we need to attach them to events in the event log.

    The Start event:
    1. Open the Event Viewer and navigate to "Applications and Services Logs\Microsoft\Windows\Backup\Operational"
    2. Find a "start" event (Event ID 1), right-click and choose "Attach Task To This Event"
    3. Give the Task a useful name, like WSB-Start and click Next.
    4. Click Next.
    5. Choose "Start a program"
    6. Click Browse and choose "C:\Program Files\EmailNotification\BackupStart.bat", click Open, click Next
    7. Check the "Open the Properties dialog for this task when I click Finish" and click Finish
    8. Select the radio button "Run whether user is logged on or not" and check "Do not store password. The task will only have access to local computer resources."
    9. Click OK.

    The Success event:
    10. Open the Event Viewer and navigate to "Applications and Services Logs\Microsoft\Windows\Backup\Operational"
    11. Find a "success" event (Event ID 4), right-click and choose "Attach Task To This Event"
    12. Give the Task a useful name, like WSB-Success and click Next.
    13. Click Next.
    14. Choose "Start a program"
    15. Click Browse and choose "C:\Program Files\EmailNotification\BackupSuccess.bat", click Open, click Next
    16. Check the "Open the Properties dialog for this task when I click Finish" and click Finish
    17. Select the radio button "Run whether user is logged on or not" and check "Do not store password. The task will only have access to local computer resources."
    18. Click OK.

    The failure event is more tricky as multiple events need to be trapped:
    19. Open Task Scheduler (win key+type "task scheduler"
    20. In the tree on the left navigate to "Event Viewer Tasks"
    21. Click "Create Task" in the right pane
    22. Give the task a name (e.g. WSB-Failure) click the radio button "Run whether user is logged on or not" and click "Do not store password. The task will only have access to local computer resources."
    23. Click the Triggers tab
    24. Click New...
    25. Where it says "Begin the task:" choose "On an event" from the drop-down list
    26. Click the "Custom" radio button on the left and click "New Event Filter"
    27. Check all event levels (Critical, Warning, Verbose, Error, Information)
    28. In the "Event logs" dropdown list, navigate to "Applications and Services Logs\Microsoft\Windows\Backup\Operational" and check it
    29. Click the arrow beside the "Event logs" box to make the drop-down box go away
    30. Click on the text box that says "<All Event IDs>"
    31. We need to enter all the "failure" Event IDs, here's a list to paste: 5,9,17-22,49,50,52,517,518,521,527,528,544-546,561,564
    32. Click OK
    33. Click OK
    34. Click the Actions tab
    35. Click New...
    36. Click the Browse button and choose "C:\Program Files\EmailNotification\BackupFailure.bat"
    37. Click OK
    38. ...and click OK to actually create the new task.

    Now all the tasks are created. Now you just need to let the backup run and you should get notifications.

    • Marked as answer by Gary S. Wong Friday, June 14, 2013 6:26 PM
    Thursday, June 13, 2013 10:24 PM

All replies

  • Hi,

    I think we could set a trigger in task schedule based on event log and send email notification.

    A similar thread could be found here:

    http://social.technet.microsoft.com/Forums/en-US/windowsbackup/thread/bcd72564-5763-4390-8626-bf3ecdea9d63


    TechNet Subscriber Support in forum |If you have any feedback on our support, please contact tnmff@microsoft.com.

    Thursday, May 30, 2013 9:10 AM
  • Thanks for the info. However, the custom task to Event has been deprecated on Windows Server 2012. I was using this Task Scheduler feature for the last 3 years for Windows server 2008 R2, but Windows Server 2012 does not provide this anymore.
    Friday, May 31, 2013 12:04 AM
  • Hi,

    If there is any misunderstanding please just correct me.

    In Event Viewer, you could find the event log you need and right click on it, choose Attach Task To This Event and follow the wizard to send an email as notification.

    Wednesday, June 05, 2013 4:05 AM
  • See this screen capture, the "Send an e-mail (deprecated)".

    Wednesday, June 05, 2013 5:37 PM
  • Hi Shaon,

    Any update on solution?

    Tuesday, June 11, 2013 7:03 PM
  • Hi Gary

    I also couldn't figure out why they deprecated this feature. You can still have notifications but you will need to write a script to do this for you.

    I used blat (which is a Windows command line mailer) combined with custom task scheduler entries to monitor the event IDs necessary.

    Unfortunately you have to write a batch file or similar that runs blat to send out the required messages.

    Generally speaking, I set up three different scripts:
    Success: Event ID 4
    Start: Event ID 1
    Failure: Event IDs 5,9,17-22,49,50,52,517,518,521,527,528,544-546,561,564

    If you aren't comfortable with using blat there are some VBS scripts out there that do the same thing.

    As far as I can tell, there is no way to get the old behaviour back.

    I don't have a step by step but can probably make one if you are interested.
    • Edited by danjqf Thursday, June 13, 2013 4:08 PM
    Thursday, June 13, 2013 4:06 PM
  • Hi danjqf,

    Thanks very much for the input. Yes I am very interested in getting the step by step solution because I am not a scripting guy!

    Thursday, June 13, 2013 4:17 PM
  • OK. It's not terribly difficult, just a few batch files.

    Here's a step-by-step using blat. Items in greater than/less than symbols (e.g. <ServerIP>) need to be changed to suit your environment.


    1. Download blat (www.blat.net or blat.sourceforge.net)
    2. Install blat. Extract the archive and copy the files in the Full directory in the archive to a directory (if multiple applications are using it you might want to put it somewhere in the PATH, like %window%\system32)
    3. Configure blat. Basically this means setting the IP address of the receiving mail server and a FROM email address (mail sent by blat will appear sent by the email address you set here):
          blat -install <MailServerIP> <FROMEmailAddress>

          As an example, if your mail server address is 192.168.0.10 and the email address you want the emails to use is WSB-Server@backup.local:
              blat -install 192.168.0.10 WSB-Server@backup.local
    4. Create a new directory in Program Files called EmailNotification
    5. Create a few text files in the EmailNotification directory (these will be the bodies of the emails sent on notification):
          File: BackupFailure.txt
          Contents: WSB (<ServerRunningWSB>): The backup failed.

          File: BackupStart.txt
          Contents: WSB (<ServerRunningWSB>): The backup has started.

          File: BackupSuccess.txt
          Contents: WSB (<ServerRunningWSB>): The backup completed successfully.
    6. Create a few batch files in the EmailNotification directory to actually send the emails:
          File: BackupFailure.bat
          Contents: @blat "C:\Program Files\EmailNotification\BackupFailure.txt" -to <DestinationEmailAddress> -subject "WSB (<ServerRunningWSB>): Backup failed."

          File: BackupStart.bat
          Contents: @blat "C:\Program Files\EmailNotification\BackupStart.txt" -to <DestinationEmailAddress> -subject "WSB (<ServerRunningWSB>): Backup started."


          File: BackupSuccess.bat
          Contents: @blat "C:\Program Files\EmailNotification\BackupSuccess.txt" -to <DestinationEmailAddress> -subject "WSB (<ServerRunningWSB>): Backup completed successfully."
    7. Now test them to see if they send email, open a command prompt, change to the "C:\Program Files\EmailNotification" directory and run each batch file manually to make sure mail is getting through. It's important to run this in the command prompt as it echoes what it's doing, so if they're problems it'll tell you. If you have problems getting the emails through you need to fix it at this step. Firewalls or SMTP rules may need to be created to allow the emails through.


    The installation and configuration of the scripts is now done. Now we need to attach them to events in the event log.

    The Start event:
    1. Open the Event Viewer and navigate to "Applications and Services Logs\Microsoft\Windows\Backup\Operational"
    2. Find a "start" event (Event ID 1), right-click and choose "Attach Task To This Event"
    3. Give the Task a useful name, like WSB-Start and click Next.
    4. Click Next.
    5. Choose "Start a program"
    6. Click Browse and choose "C:\Program Files\EmailNotification\BackupStart.bat", click Open, click Next
    7. Check the "Open the Properties dialog for this task when I click Finish" and click Finish
    8. Select the radio button "Run whether user is logged on or not" and check "Do not store password. The task will only have access to local computer resources."
    9. Click OK.

    The Success event:
    10. Open the Event Viewer and navigate to "Applications and Services Logs\Microsoft\Windows\Backup\Operational"
    11. Find a "success" event (Event ID 4), right-click and choose "Attach Task To This Event"
    12. Give the Task a useful name, like WSB-Success and click Next.
    13. Click Next.
    14. Choose "Start a program"
    15. Click Browse and choose "C:\Program Files\EmailNotification\BackupSuccess.bat", click Open, click Next
    16. Check the "Open the Properties dialog for this task when I click Finish" and click Finish
    17. Select the radio button "Run whether user is logged on or not" and check "Do not store password. The task will only have access to local computer resources."
    18. Click OK.

    The failure event is more tricky as multiple events need to be trapped:
    19. Open Task Scheduler (win key+type "task scheduler"
    20. In the tree on the left navigate to "Event Viewer Tasks"
    21. Click "Create Task" in the right pane
    22. Give the task a name (e.g. WSB-Failure) click the radio button "Run whether user is logged on or not" and click "Do not store password. The task will only have access to local computer resources."
    23. Click the Triggers tab
    24. Click New...
    25. Where it says "Begin the task:" choose "On an event" from the drop-down list
    26. Click the "Custom" radio button on the left and click "New Event Filter"
    27. Check all event levels (Critical, Warning, Verbose, Error, Information)
    28. In the "Event logs" dropdown list, navigate to "Applications and Services Logs\Microsoft\Windows\Backup\Operational" and check it
    29. Click the arrow beside the "Event logs" box to make the drop-down box go away
    30. Click on the text box that says "<All Event IDs>"
    31. We need to enter all the "failure" Event IDs, here's a list to paste: 5,9,17-22,49,50,52,517,518,521,527,528,544-546,561,564
    32. Click OK
    33. Click OK
    34. Click the Actions tab
    35. Click New...
    36. Click the Browse button and choose "C:\Program Files\EmailNotification\BackupFailure.bat"
    37. Click OK
    38. ...and click OK to actually create the new task.

    Now all the tasks are created. Now you just need to let the backup run and you should get notifications.

    • Marked as answer by Gary S. Wong Friday, June 14, 2013 6:26 PM
    Thursday, June 13, 2013 10:24 PM
  • It works like magic!!

    Thanks very much danjqf!!

    Friday, June 14, 2013 6:28 PM