How to track Windows Server 2008 backups have been successful (or not)


If you’re using Windows Server Backup on Windows Server 2008, and would like an email to tell you whether the backup has been successful or not, here’s how to do it.

First, you will need to know how Windows Server Backup works, as well as a reasonable working knowledge of Task Scheduler.

Overview of how it works

In Task Scheduler, create two Event Viewer Tasks that trigger on an event

Log: Microsoft-Windows-Backup/Operational

Source: Backup

The success Event ID is 14

The fail Event ID is 49

The action is to start a program (a visual basic macro, one that sends a fail email, one that sends a success email).

The Nitty-Gritty

Our exported tasks are as follows – you will need to copy and paste this text into a file (we use Notepad++), then replace MYDOMAIN\administrator with your own admin domain and user name. Now save the files as e.g. fail.xml and success.xml and try importing them into Task Manager. To import them, right-click on the folder Event Viewer Tasks and select Import Task.

Make sure the tasks are running with the highest privileges and configured for Windows Vista, Windows Server 2008.

FAIL TASK:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2011-01-24T16:38:03.3232898</Date>
    <Author>MYDOMAIN\administrator</Author>
  </RegistrationInfo>
  <Triggers>
    <EventTrigger>
      <Enabled>true</Enabled>
      <Subscription>&lt;QueryList&gt;&lt;Query Id="0" Path="Microsoft-Windows-Backup"&gt;&lt;Select Path="Microsoft-Windows-Backup"&gt;*[System[Provider[@Name='Microsoft-Windows-Backup'] and EventID=49]]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;</Subscription>
    </EventTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>MYDOMAIN\administrator</UserId>
      <LogonType>InteractiveToken</LogonType>
      <RunLevel>LeastPrivilege</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>P3D</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>"C:\Program Files (x86)\backup-track\send_fail_email.vbs"</Command>
      <WorkingDirectory>C:\Program Files (x86)\cwRsync</WorkingDirectory>
    </Exec>
  </Actions>
</Task>

Success Task:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2011-01-24T16:51:30.2125174</Date>
    <Author>MYDOMAIN\administrator</Author>
  </RegistrationInfo>
  <Triggers>
    <EventTrigger>
      <Enabled>true</Enabled>
      <Subscription>&lt;QueryList&gt;&lt;Query Id="0" Path="Microsoft-Windows-Backup"&gt;&lt;Select Path="Microsoft-Windows-Backup"&gt;*[System[Provider[@Name='Microsoft-Windows-Backup'] and EventID=14]]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;</Subscription>
    </EventTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>MYDOMAIN\administrator</UserId>
      <LogonType>InteractiveToken</LogonType>
      <RunLevel>LeastPrivilege</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>P3D</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>"C:\Program Files (x86)\backup-track\send_success_email.vbs"</Command>
      <WorkingDirectory>C:\Program Files (x86)\cwRsync</WorkingDirectory>
    </Exec>
  </Actions>
</Task>

Fail visual basic script (save as send_fail_email.vbs in C:\Program Files (x86)\backup-track). Where I’ve put MAILSERVER we had SERVERNAME.MYDOMAIN.LOCAL, you might need something else.

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Local backup of SERVERNAME failed"
objMessage.From = "myemail@mycompany.com"
objMessage.TextBody = "Aaargh"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "MAILSERVER"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update

objMessage.To = "myemail@mycompany.com"
objMessage.Send
objMessage.To = "mycolleague@mycompany.com"
objMessage.Send

Success visual basic script (save as send_success_email.vbs in C:\Program Files (x86)\backup-track)

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Local backup of SERVERNAME OK"
objMessage.From = "myemail@mycompany.com"
objMessage.TextBody = "Hooray!"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "MAILSERVER"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update

objMessage.To = "myemail@mycompany.com"
objMessage.Send
objMessage.To = "mycolleague@mycompany.com"
objMessage.Send

Good luck!

Advertisements

About saasmd

I am an experienced software-as-a-service entrepreneur, based in London, UK. I love building interesting software businesses. My current venture is StorIQ, a platform to help bricks-and-mortar retailers manage their operations more effectively. This blog is a space to share low-level techie stuff that I think other people will find useful.
This entry was posted in Techy Stuff. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s