Thursday, December 16, 2010

Automatically Print Server 2008 Backup Confirmation/Results Logs

Please Note This Does Not Work For Server 2008 R2.  MS opted to axe the plaintext files.  Back to the drawing board . . .  I'll be using the tips at http://www.techrepublic.com/blog/networking/four-ways-to-manage-windows-server-2008-backup-on-multiple-servers/4159 in the mean time.

For a year I've looked for a way to confirm Server 2008 backup results without regularly logging in and examining the Server Manager, perusing the System Logs, or buying a backup software package.  Windows Backup makes quite readable reports in the \%systemfolder%\logs\WindowsServerBackup\ folder that can be viewed in Notepad.  These files are created upon the completion of each backup, and seem to stick around for a couple of weeks.

Scheduling the following .bat files to run after your backup has completed will yield printed backup reports that will list what is backed up in the first report, then a second report with any exceptions which will be blank except for the number "1" in the bottom center of the page if there are no exceptions.

Create a text file called prtbaklog.bat containing the following:

@echo off
setlocal
if {%1}=={} @echo Syntax PrintDevice (\\Server\Printer)
set device=%1
set prt=N
for /f "Tokens=*" %%i in ('dir /o-d /b "C:\windows\logs\WindowsServerBackup\Backup-*.log"') do call :print %%i
endlocal
goto :EOF
:print
if not "%prt%" EQU "N" goto :EOF
set prt=Y
"C:\Program Files\Windows NT\Accessories\wordpad.exe" /pt "C:\windows\logs\WindowsServerBackup\%1" %device%
The  prtbaklog.bat is invoked with the following command syntax:

prtbaklog.bat \\servername\printername


Next create the following .bat file entitled prtbakfail.bat"

@echo off
setlocal
if {%1}=={} @echo Syntax PrintDevice (\\Server\Printer)
set device=%1
set prt=N
for /f "Tokens=*" %%j in ('dir /o-d /b "C:\windows\logs\WindowsServerBackup\Backup_Error*.log"') do call :print %%j
endlocal
goto :EOF
:print
if not "%prt%" EQU "N" goto :EOF
set prt=Y
"C:\Program Files\Windows NT\Accessories\wordpad.exe" /pt "C:\windows\logs\WindowsServerBackup\%1" %device%
Again, schedule it to run after your backup has completed with the command syntax:

prtbakfail.bat \\servername\sharename

1 comment:

Anonymous said...

Justin - My name is Jason Johnson. I was just passing by your blog. I think we have a lot in common! Anyways I have a peice of software I created (vb.net) called backup noticed that you can schedule to run once a day and it will email out the results of a your server 2008 backups. it is 1 exe file about .5 mb and a xml file with some settings. This was my only 1 issue with using the built in backups. My email account is jason@johnsonts.com