Last active
May 4, 2023 08:27
-
-
Save mritsurgeon/40293dafc97a700789ab3dc906fea89b to your computer and use it in GitHub Desktop.
Check Fast clone Health with Veeam
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$verbose=$False;if ($args[0] -eq "-verbose" -or $args[0] -eq "--v") {$verbose=$True;write-output ""} | |
$info="Started "+(date) | |
write-output $info | |
$logpath="C:\ProgramData\Veeam\Backup" | |
$disp="Check for fastclone in backup logs for server "+(hostname) | |
write-output $disp | |
$jobs=(Get-VBRJob | ?{$_.jobtype -eq "Backup"}) | |
$data=@(); | |
foreach ($j in ($jobs)) { | |
if ($j.findlastsession().iscompleted) {$tmp="Processing"} else {$tmp="Skipped"} | |
$data+=[pscustomobject]@{ | |
Name=($j.LogNameMainPart) ; | |
LatestStart=$j.findlastsession().progress.StartTimeLocal.tostring("yyyy-MM-dd HH:mm:ss"); | |
LatestStop=$j.findlastsession().progress.StopTimeLocal.tostring("yyyy-MM-dd HH:mm:ss"); | |
Running=(-not $j.findlastsession().iscompleted); | |
Percent=($j.findlastsession().progress.percents); | |
Result=$tmp | |
} | |
} | |
write-output $data | ft | |
Write-host "Scanning..." | |
$i=0 | |
foreach ($d in ($data)) { | |
try {$log=Get-Content $($logpath + "\" + $d.name.replace(" ","_") + "\Job*.log") -erroraction stop} | |
catch {$data[$i].Result="File missing"} | |
$log=(gc -erroraction silentlycontinue $($logpath + "\" + $d.name.replace(" ","_") + "\Job*.log") | %{$_ -replace '^\[(..).(..).(....)','[$3-$2-$1'} | %{ if ([regex]::match($_,'^\[[0-9]{4}.[0-9]{2}.[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\]').Value -gt "["+$d.LatestStart) {$_}}) | |
Write-host $d.name | |
if ($data[$i].Result -eq "Processing") { | |
$last = ($log | Select-String -Pattern ".*fast clone" -AllMatches | select-object -last 1) | |
#$last = ($log | %{if ([regex]::match($_,".*fast clone")){$_}}| select-object -last 1) | |
if ($last -eq $null) { | |
$data[$i].Result="Not Found !" | |
} | |
else { | |
$data[$i].Result = $last.tostring().substring(0,21) | |
} | |
} | |
$i=$i+1 | |
} | |
write-output "" | |
$data | out-gridview -title "$disp" | |
$data | ft | |
$info="Ended "+(date) | |
write-output $info | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment