Saturday, 12 November 2011

Automated email notification for Windows backup

The native backup utility found on Windows servers is one cool application that has saved many SMBs real cash! Apart from fulfilling its main functionality, it is found to be very reliable and effective. Problems arise when extra features are required such as, backing up to external storage devices and/or utilizing advanced backup features! One useful feature that is standard in purchasable applications is email notification of backup jobs. The script below gives you that functionality!!!! It’s free and simple to implement!!!!

The implementation steps of the script are as follows:

1. Create a backup job using Windows backup – Start/All Programs/Accessories/System Tools/Backup and set a job schedule
2. Open the window Scheduled Tasks – Start/Control Panel/Scheduled Tasks and find the newly created scheduled job.
3. From the properties window of this job copy the highlighted text from the Run text field
4. Copy this text in a new batch file called ‘mybackup.bat’ (any name you like without quotes)
5. Take a note of the batch file location and enter the full path in the Run text field of step 3 ex: c:\documents\mybackup.bat
6. Close the properties window by clicking OK and enter an admin password if prompted
7. Add the sample script shown below in the batch file after the text entered in step 4
8. Edit the script text to reflect your email & path settings

Sample script

Copied text from step 3 goes here

@echo off
set Sender=”source email addess”
set Receiver=”your email address”
set Host=”IP address of source email server”
set Subject=”Backup name/title”

set logdir=”%USERPROFILE%\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data”
REM ex – C:\Documents and Settings\administrator\ for %USERPROFILE%
set result=”%temp%\latestlog.txt”

pushd %logdir%
for /f “tokens=1 delims=” %%I in (‘dir /B /O-D’) do (
if “%%~xI”==”.log” (
type “%%~fI” > %result%
goto :end
)
)
:end
popd

c:\windows\system32\blat.exe %result% -f %Sender% -to %Receiver% -server %Host% -subject %Subject%
del /q /f “%result%”

No comments:

ISM Cyber Security Terms

ISM Cyber Security Terms