Veeam Backup Validator PowerShell Pester Test

Um auch über neue Artikel auf Englisch informiert zu werden, einfach den neuen RSS Feed abonnieren.

 

 

Diese Woche wurde mir wieder einmal ein sehr unterschätztes Tool für Veeam Backup & Replication ins Bewusstsein gerufen, der Veeam Backup Validator. Mit diesem Kommandozeilentool können die Veeam Backup Files überprüft werden. Die Syntax ist relativ simpel aber aufwendig wenn man eine große Anzahl von Backups überprüfen möchte. Um die Validierung großer Mengen an Backup Jobs und Backup Files so einfach wie möglich zu gestalten, habe ich mir einen Veeam Backup Validator PowerShell Pester Test geschrieben.

Veeam Backup Validator PowerShell Pester Test

Der von mir verfasste Pester Test besteht aus zwei Teilschritten:

  1. Backup Files der aktuell vorhandenen Jobs überprüfen
  2. Überprüfung der Veeam Backup Metadata Files unterhalb des Pfades des Pester Test Skript

Bitte bei der Ausführung beachten, dass durch den Veeam Backup Validator enorm Disk Read erzeugt werden kann:

Veeam Backup Validator Test load

Veeam Backup Validator für Backup Jobs

Dieser Test ist der aufwendigere der Beiden, denn hier muss zu aller erst eine Verbindung zum Veeam Backup & Replication Server hergestellt werden um die aktuellen Jobs auszulesen. Mit diesen Informationen kann dann der Veeam Backup Validator gestartet werden.

Beispiel:

veeam.backup.validator.exe /backup:"Backup Job 1"

Um jedoch den Veeam Backup Validator Pester Test zu realisieren werden die Ergebnisse in ein XML File geschrieben, welches dann wieder ausgewertet wird.

veeam.backup.validator.exe /silence /format:xml /report:"C:\temp.report.xml" /backup:"Backup Job 1"

XML Ausgabe:

<?xml version="1.0" encoding="utf-8"?>
<Report>
  <Info>Veeam Backup Validator Version 9.5.0.0
Copyright © Veeam Software AG. All rights reserved.</Info>
  <Info>Parameters:</Info>
  <Parameters>
    <Parameter Name="File:">D:\Backup\Backup Job 1\Backup Job 1.vbm</Parameter>
    <Parameter Name="Format:">Xml</Parameter>
    <Parameter Name="Report:">D:\Backup Job 1.vbm.xml</Parameter>
    <Parameter Name="Silence:">yes</Parameter>
    <Parameter Name="Skip:">no</Parameter>
  </Parameters>
  <VMProcessing>
    <Info>Reading file summary...</Info>
    <FileSummary>
      <Parameter Name="Storage path:">D:\Backup\Backup Job 1\Backup Job 1D2017-08-25T215407.vbk, D:\Backup\Backup Job 1\Backup Job 1D2017-09-04T223507.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T215841.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T223707.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224001.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224655.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224816.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T214632.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T221631.vbk</Parameter>
      <Parameter Name="D:\Backup\Backup Job 1\Backup Job 1D2017-08-25T215407.vbk, D:\Backup\Backup Job 1\Backup Job 1D2017-09-04T223507.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T215841.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T223707.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224001.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224655.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224816.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T214632.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T221631.vbk">summary.xml (8,9 KB)</Parameter>
      <Parameter Name="D:\Backup\Backup Job 1\Backup Job 1D2017-08-25T215407.vbk, D:\Backup\Backup Job 1\Backup Job 1D2017-09-04T223507.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T215841.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T223707.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224001.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224655.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224816.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T214632.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T221631.vbk">test2.vmx (2,7 KB)</Parameter>
      <Parameter Name="D:\Backup\Backup Job 1\Backup Job 1D2017-08-25T215407.vbk, D:\Backup\Backup Job 1\Backup Job 1D2017-09-04T223507.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T215841.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T223707.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224001.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224655.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224816.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T214632.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T221631.vbk">test2.nvram (8,5 KB)</Parameter>
      <Parameter Name="D:\Backup\Backup Job 1\Backup Job 1D2017-08-25T215407.vbk, D:\Backup\Backup Job 1\Backup Job 1D2017-09-04T223507.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T215841.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T223707.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224001.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224655.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224816.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T214632.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T221631.vbk">test2.vmdk (542,0 B)</Parameter>
      <Parameter Name="D:\Backup\Backup Job 1\Backup Job 1D2017-08-25T215407.vbk, D:\Backup\Backup Job 1\Backup Job 1D2017-09-04T223507.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T215841.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T223707.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224001.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224655.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224816.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T214632.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T221631.vbk">test2-flat.vmdk (16,0 GB)</Parameter>
      <Parameter Name="D:\Backup\Backup Job 1\Backup Job 1D2017-08-25T215407.vbk, D:\Backup\Backup Job 1\Backup Job 1D2017-09-04T223507.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T215841.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T223707.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224001.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224655.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224816.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T214632.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T221631.vbk">FsAwareMeta:eb386d08-554e-4369-bfc4-619c6ec17df6:2000 (100,0 B)</Parameter>
      <Parameter Name="D:\Backup\Backup Job 1\Backup Job 1D2017-08-25T215407.vbk, D:\Backup\Backup Job 1\Backup Job 1D2017-09-04T223507.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T215841.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T223707.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224001.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224655.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224816.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T214632.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T221631.vbk">summary.xml (8,6 KB)</Parameter>
      <Parameter Name="D:\Backup\Backup Job 1\Backup Job 1D2017-08-25T215407.vbk, D:\Backup\Backup Job 1\Backup Job 1D2017-09-04T223507.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T215841.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T223707.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224001.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224655.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224816.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T214632.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T221631.vbk">test.vmx (1,9 KB)</Parameter>
      <Parameter Name="D:\Backup\Backup Job 1\Backup Job 1D2017-08-25T215407.vbk, D:\Backup\Backup Job 1\Backup Job 1D2017-09-04T223507.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T215841.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T223707.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224001.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224655.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224816.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T214632.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T221631.vbk">test.vmdk (540,0 B)</Parameter>
      <Parameter Name="D:\Backup\Backup Job 1\Backup Job 1D2017-08-25T215407.vbk, D:\Backup\Backup Job 1\Backup Job 1D2017-09-04T223507.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T215841.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T223707.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224001.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224655.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224816.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T214632.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T221631.vbk">test-flat.vmdk (16,0 GB)</Parameter>
      <Parameter Name="D:\Backup\Backup Job 1\Backup Job 1D2017-08-25T215407.vbk, D:\Backup\Backup Job 1\Backup Job 1D2017-09-04T223507.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T215841.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T223707.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224001.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224655.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-09-05T224816.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T214632.vib, D:\Backup\Backup Job 1\Backup Job 1D2017-11-05T221631.vbk">FsAwareMeta:29cf5dc5-cba2-4d5b-8701-4c6b1bfb8cb5:2000 (100,0 B)</Parameter>
    </FileSummary>
    <Progress>
      <Info>Validating test2.vmx</Info>
      <FileName>test2.vmx</FileName>
      <Percentage>100</Percentage>
    </Progress>
    <Progress>
      <Info>Validating test2.nvram</Info>
      <FileName>test2.nvram</FileName>
      <Percentage>100</Percentage>
    </Progress>
    <Progress>
      <Info>Validating test2.vmdk</Info>
      <FileName>test2.vmdk</FileName>
      <Percentage>100</Percentage>
    </Progress>
    <Progress>
      <Info>Validating test2-flat.vmdk</Info>
      <FileName>test2-flat.vmdk</FileName>
      <Percentage>100</Percentage>
    </Progress>
    <Progress>
      <Info>Validating FsAwareMeta:eb386d08-554e-4369-bfc4-619c6ec17df6:2000</Info>
      <FileName>FsAwareMeta:eb386d08-554e-4369-bfc4-619c6ec17df6:2000</FileName>
      <Percentage>100</Percentage>
    </Progress>
    <Progress>
      <Info>Validating test.vmx</Info>
      <FileName>test.vmx</FileName>
      <Percentage>100</Percentage>
    </Progress>
    <Progress>
      <Info>Validating test.vmdk</Info>
      <FileName>test.vmdk</FileName>
      <Percentage>100</Percentage>
    </Progress>
    <Progress>
      <Info>Validating test-flat.vmdk</Info>
      <FileName>test-flat.vmdk</FileName>
      <Percentage>100</Percentage>
    </Progress>
    <Progress>
      <Info>Validating FsAwareMeta:29cf5dc5-cba2-4d5b-8701-4c6b1bfb8cb5:2000</Info>
      <FileName>FsAwareMeta:29cf5dc5-cba2-4d5b-8701-4c6b1bfb8cb5:2000</FileName>
      <Percentage>100</Percentage>
    </Progress>
  </VMProcessing>
  <Statistics>
    <Parameter Name="Backup files count:">9</Parameter>
    <Parameter Name="Incomplete backup files count:">0</Parameter>
    <Parameter Name="Failed backup files count:">0</Parameter>
    <Parameter Name="Files count:">9</Parameter>
    <Parameter Name="Total size:">32,0 GB</Parameter>
  </Statistics>
  <ResultInfo>
    <Result>Success</Result>
    <Info>Validation completed successfully.</Info>
  </ResultInfo>
  <DateInfo>Created by VEEAM-01\Administrator at 08.11.2017 22:45:52</DateInfo>
</Report>

Um alle Veeam Backup Jobs in einem PowerShell Skript zu validieren hat unter anderem Christopher Glémot bereits einen tollen Artikel veröffentlicht.

Veeam Backup Validator für Backup Files

Der zweite Test könnte ohne eine Verbindung zum Veeam Backup & Replication Server durchführt werden. Es werden nur die *.vbm Files (Veeam Backup Metadata File) in dem Pfad des Pester Test Skripts rekursiv aufgelistet und überprüft.

Beispiel:

veeam.backup.validator.exe /file:"G:\Backups\Management\Management.vbm"

Die XML Ausgabe würde wieder nach dem gleichen Schema funktionieren (HTML ginge natürlich auch, ist aber komplexer zu verarbeiten).

Veeam Backup Validator Pester Test Skript

Ein Aufruf einer externen Applikation ist in PowerShell für gewöhnlich kein Problem und es gibt verschiedenste Wege das zu tun. Die veeam.backup.validator.exe ist jedoch, wie sich herausgestellt hat sehr empfindlich. Daher in diesem Skript der aufwendige Aufruf über Start-Process. Auch in der PowerShell ISE bitte nicht wundern wenn Backups als fehlerhaft angezeigt werden (Hier ein Beitrag aus dem Veeam Forum: Problem running „Veeam.Backup.Validator.exe“ in PowerShell).

<#
    .EXAMPLE
    Invoke-Pester -Script @{ Path = "D:\VeeamBackupValidator.Tests.ps1"; Parameters = @{ BRHost="localhost"} }
#>

$BRHost = $Parameters.Get_Item("BRHost")

Describe "Veeam Backup Validator" {

    Add-PsSnapin -Name VeeamPSSnapIn
    $OpenConnection = (Get-VBRServerSession).Server
    if($OpenConnection -eq $BRHost) {
    } elseif ($OpenConnection -eq $null ) {
	    Connect-VBRServer -Server $BRHost
        } else {
            Disconnect-VBRServer
            Connect-VBRServer -Server $BRHost
            }

    $Jobs = Get-VBRBackup

    $testCase = $Jobs | Foreach-Object {@{Job = $_.name}}
    It "Backup File for Job '<Job>' should be valid " -TestCases $testCase {
        param($Job)

        [String] $Report = $PSScriptRoot + $Job + ".xml"
        $EXEPath = $env:ProgramFiles + "\Veeam\Backup and Replication\Backup\veeam.backup.validator.exe"
        Start-Process $EXEPath  " /silence /format:xml /report:`"$Report`" /backup:`"$Job`" " -Wait
        $Report | Should Exist
        $XMLContent = [XML] (Get-Content $report )
        (($XMLContent.Report.Statistics.Parameter | Where-Object {$_.Name -eq "Failed VM count:"})."#text") | Should Be 0
        Remove-Item $Report -Force
    }

    $Backups = Get-ChildItem $PSScriptRoot -Include *.vbm -Recurse
    $testCase = $Backups | Foreach-Object {@{file = $_}}
    It "Backup File  '<file>' should be valid" -TestCases $testCase {
        param($File)

        [String] $Report = $PSScriptRoot + $File.name + ".xml"
        $EXEPath = $env:ProgramFiles + "\Veeam\Backup and Replication\Backup\veeam.backup.validator.exe"
        Start-Process $EXEPath  " /silence /format:xml /report:`"$Report`" /file:`"$File`" " -Wait
        $Report | Should Exist
        $XMLContent = [XML] (Get-Content $Report )
        (($XMLContent.Report.Statistics.Parameter | Where-Object {$_.Name -eq "Failed backup files count:"})."#text") | Should Be 0
        Remove-Item $Report -Force
    }

}

 

Share with:

Leave a Reply