Quantcast
Channel: Annoying stuff I figured out (or am trying to) » event viewer
Viewing all articles
Browse latest Browse all 2

Windows Backup logging start and end times

$
0
0

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



Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images