Windows Backup logging start and end times

Posted: May 28, 2013 in Information, Windows General
Tags: , , , , , ,

Here’s a quick script I’ve written to generate a log of my servers windows backup results. It connects to each server and log the start time of the backup operation and the “Successful” time. If there is no “success” due to an error then it just won’t return anything.

There is also a section at the end which has been disabled (remove the :: if you want to use it) that will return all the backup events for the last 24 hours. That will give you more info about failures if you need them logged as well.
@echo off

set log=C:\logfiles\backup.txt

echo %date% %time% >%log%
echo. >>%log%

set target=servername1
call :getevt

set target=servername2
call :getevt

set target=servername3
call :getevt

set target=servername4
call :getevt

goto end

:getevt
echo *** %target% *** >>%log%
Echo Start: >>%log%
wevtutil qe microsoft-windows-backup /r:%target% /q:”*[System[(EventID=1) and TimeCreated[timediff(@SystemTime) >%log%
echo. >>%log%

Echo End: >>%log%
wevtutil qe microsoft-windows-backup /r:%target% /q:”*[System[(EventID=4) and TimeCreated[timediff(@SystemTime) >%log%
echo. >>%log%
echo. >>%log%

::Echo Last 24 hours: >>%log%
::wevtutil qe microsoft-windows-backup /r:%target% /q:”*[System[TimeCreated[timediff(@SystemTime) >%log%
goto :eof

:end

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