Windows Server Backup – Email Notification

For Small Business it is not easy to have a cheap backup solution. There is always something missing, incremental backup, mail notifications, etc…

Therefore i went online and started searching, backup and notification. I came across this thread on Technet Microsoft:

Technet Forum – Windows Backup Notification

In short:

We can use Blat (command line tool that let you send emails with email authentication.) or we can make use of native Powershell commands (if you do not want to use 3th party tools):

Blat Version:

We make use of the Event Viewer and use Schelduled Tasks that Trigger on an event

To make things Easy, I have already have an 2008R2 and 2012R2 Templates that you can import as a Schelduled Task. (these use the blat version)

2008r2

2012r2

Next, Make a folder in

C:\Program Files\EmailNotification\

Create 3 files:

BackupFailure.txt

 The backup failed.

BackupStart.txt

 The backup started.

BackupSuccess.txt

 The backup completed successfully.

We have to make a bat file for each

@blat "C:\Program Files\EmailNotification\BackupFailure.txt" -to DestinationEmailAddress -subject "Backup Failed."
@blat "C:\Program Files\EmailNotification\BackupStarted.txt" -to DestinationEmailAddress -subject "Backup Started."
@blat "C:\Program Files\EmailNotification\BackupSuccess.txt" -to DestinationEmailAddress -subject "Backup completed successfully."

 

Powershell Version:

Save your credentials in ‘sort of secure way’. I recommended creating a seperate account for this (this will be used to authenticate to the mailserver):

$cred = Get-Credential
$cred | Export-CliXml c:\temp\cred.clixml

import the blat version of scheduled tasks, replace the commands then with this script, and adjust accordantly with success, started and fail attempts. Notice the UseSSL (if you want to make use of it)

$From = "from@yourmailaddress.eu"
$To = "to@something.eu"
$Subject = "Backup Fail / Success / Started"
$Body = "Backup Has failed / success /Started"
$SMTPServer = youremailserver
$SMTPPort = youremailserverport
$cred2 = Import-CliXml c:\temp\cred.clixml
$Attachment = "C:\something.txt"
Send-MailMessage -From $From -to $To -Cc $Cc -Subject $Subject -Body $Body -SmtpServer $SMTPServer -port $SMTPPort -UseSsl -Credential $cred2 -Attachments $Attachment

The next issue I have with Windows Server Backup is the inability to have more than 2 backup versions:

First Method:

When you set a backup with server backup, Server Backup just makes a scheduled task. Just make an export of your Windows backup Task and make a new one with server Backup redirecting the backup to a second folder.
Import the first backup back in Task scheduler. Change the trigger of you first backupset to run each other day. Then do the same with your second backup set.

Alternative method and more easy: is to backup the backup. Just use a powershell script and set the schedule task:

gci \\backupNewLocation\backupfolder\ -recurse | remove-item -recurse -force
cp \\backuplocaltion\backupfolder \\backupNewLocation\backupfolder

You can add the following line to launch Windows Backup afterwards (do not schedule the backup in your Server Backup Console)

schtasks.exe /run "Scheduled Task Name"

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.