PowerShell script exchange
Post Reply
falkob
Veeam Vanguard
Posts: 86
Liked: 31 times
Joined: Sep 28, 2017 7:47 am
Full Name: Falko Banaszak
Contact:

Veeam Backup Validator PowerShell GUI

Post by falkob » 4 people like this post

Hi all,

i have created a PowerShell GUI which triggers the Veeam.Backup.Validator.exe

Image

At the current version, you are able to choose a .vbk or .vbm file to validate your backups in it.
After you chose a file, you can select whether you want a XML or HTML report. By chosing an output folder, the GUI starts to validate your files.

Also, you are able to see the progress, as it opens up a new cmd window where the validation happens.

Here is the code:

Code: Select all

<# 
.NAME
    Veeam Backup Validator PowerShell GUI
.SYNOPSIS
    Use this free tool to validate your Veeam Backups with the built-in Veeam.Backup.Validator.exe
.DESCRIPTION
    Released under the MIT license.
.LINK
    https://github.com/falkobanaszak
.VERSION
    0.1
#>

#region begin GLOBAL VARIABLES {
$Global:SelectedFile =$Null
$ValidatorPath = 'C:\Program Files\Veeam\Backup and Replication\Backup'
$InitialDirectory = [Environment]::GetFolderPath('Desktop')
#$ReportLocation="C:\Temp\"
$ReportName="Veeam-Backup-Validation-Report_$(get-date -f dd-MM-yyyy-hh-mm-ss)"
#endregion GLOBAL VARIABLES}


#region begin FUNCTIONS {

Function Choose-File($InitialDirectory)
{
    Add-Type -AssemblyName System.Windows.Forms
    $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
    $OpenFileDialog.Title = "Please Select File"
    $OpenFileDialog.InitialDirectory = $InitialDirectory
    $OpenFileDialog.filter = "Veeam Backup File (*.vbk)|*.vbk|Veeam Backup Metadata File (*.vbm)|*.vbm"
    If ($OpenFileDialog.ShowDialog() -eq "Cancel") 
    {
    [System.Windows.Forms.MessageBox]::Show("No File Selected. Please select a file !", "Error", 0, [System.Windows.Forms.MessageBoxIcon]::Exclamation)
    }
    $Global:SelectedFile = $OpenFileDialog.FileName
    #$OpenFileDialog.ShowDialog() | Out-Null
    
}

Function Choose-Folder($InitialDirectory)
{
    Add-Type -AssemblyName System.Windows.Forms
    $OpenFolderDialog = New-Object System.Windows.Forms.FolderBrowserDialog
    $OpenFolderDialog.ShowDialog() | Out-Null
    $Global:SelectedFolder = $OpenFolderDialog.SelectedPath
}

#endregion FUNCTIONS}

Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()
#Set-Location -Path 'C:\Program Files\Veeam\Backup and Replication\Backup'

#region begin VBVGUI{

$VBVGUI                          = New-Object System.Windows.Forms.Form
$VBVGUI.ClientSize               = '300,275'
$VBVGUI.text                     = "Veeam Backup Validator GUI"
$VBVGUI.TopMost                  = $false

$VBVGUIlblInfo                   = New-Object System.Windows.Forms.Label
$VBVGUIlblInfo.Text              = "Use this GUI to validate your Veeam Backups"
$VBVGUIlblInfo.AutoSize          = $true
$VBVGUIlblInfo.Location          = New-Object System.Drawing.Point(15,15)
$VBVGUIlblInfo.Font              = 'Microsoft Sans Serif,10'

$VBVGUIValidateButton            = New-Object System.Windows.Forms.Button
$VBVGUIValidateButton.text       = "Choose Folder and Start Validation"
$VBVGUIValidateButton.width      = 120
$VBVGUIValidateButton.height     = 40
$VBVGUIValidateButton.location   = New-Object System.Drawing.Point(90,155)

$VBVGUIChooseFile                = New-Object System.Windows.Forms.Button
$VBVGUIChooseFile.text           = "Choose .vbk or .vbm"
$VBVGUIChooseFile.width          = 120
$VBVGUIChooseFile.height         = 30
$VBVGUIChooseFile.location       = New-Object System.Drawing.Point(90,50)

$VBVGUIXMLReport                 = New-Object System.Windows.Forms.RadioButton
$VBVGUIXMLReport.text            = "Create XML Report"
$VBVGUIXMLReport.AutoSize        = $true
$VBVGUIXMLReport.width           = 104
$VBVGUIXMLReport.height          = 20
$VBVGUIXMLReport.location        = New-Object System.Drawing.Point(10,100)
$VBVGUIXMLReport.Font            = 'Microsoft Sans Serif,10'

$VBVGUIHTMLReport                = New-Object System.Windows.Forms.RadioButton
$VBVGUIHTMLReport.text           = "Create HTML Report"
$VBVGUIHTMLReport.AutoSize       = $true
$VBVGUIHTMLReport.width          = 104
$VBVGUIHTMLReport.height         = 20
$VBVGUIHTMLReport.location       = New-Object System.Drawing.Point(160,100)
$VBVGUIHTMLReport.Font           = 'Microsoft Sans Serif,10'
$VBVGUIHTMLReport.Checked        = $true

$VBVGUIDisclaimer                = New-Object System.Windows.Forms.Label
$VBVGUIDisclaimer.text           = "Copyright (c) 2019 Falko Banaszak`n`nDistributed under MIT license."
$VBVGUIDisclaimer.AutoSize       = $true
$VBVGUIDisclaimer.location       = New-Object System.Drawing.Point(35,200)
$VBVGUIDisclaimer.Font           = 'Microsoft Sans Serif,10'

#endregion VBVGUI}

$VBVGUIChooseFile.Add_Click({
Choose-File
#[System.Windows.Forms.MessageBox]::Show("The following file has been selected: $Global:SelectedFile" , "Information", 0, [System.Windows.Forms.MessageBoxIcon]::Information)
})

$VBVGUIValidateButton.Add_Click({
If ($Global:SelectedFile -eq $Null)
    {
        [System.Windows.Forms.MessageBox]::Show("No File Selected. Please select a file !", "Error", 0, [System.Windows.Forms.MessageBoxIcon]::Exclamation)
    }
else
    {

    IF ($VBVGUIXMLReport.Checked -eq "True")
        {
            Choose-Folder
            #$ReportString="$ReportLocation"+"$ReportName"+".xml"
            $ReportString="$Global:SelectedFolder"+"\"+"$ReportName"+".xml"
            Set-Location -path $ValidatorPath        
            Start-Process cmd.exe -Wait "/c .\Veeam.Backup.Validator.exe /file:$Global:SelectedFile /report:$ReportString /format:xml"
            [System.Windows.Forms.MessageBox]::Show("Validation process finished !" , "Information", 0, [System.Windows.Forms.MessageBoxIcon]::Information)
            
        }
    Else
        {
            Choose-Folder
            #$ReportString="$ReportLocation"+"$ReportName"+".html"
            $ReportString="$Global:SelectedFolder"+"\"+"$ReportName"+".html"
            Set-Location -path $ValidatorPath
            Start-Process cmd.exe -Wait "/c .\Veeam.Backup.Validator.exe /file:$Global:SelectedFile /report:$ReportString"
            [System.Windows.Forms.MessageBox]::Show("Validation process finished !" , "Information", 0, [System.Windows.Forms.MessageBoxIcon]::Information)
        }
    }
})

$VBVGUI.Controls.AddRange(@($VBVGUIlblInfo,$VBVGUIValidateButton,$VBVGUIXMLReport,$VBVGUIHTMLReport,$VBVGUIDisclaimer,$VBVGUIChooseFile))
[void] $VBVGUI.ShowDialog()
You can get the Script on my blog: https://www.virtualhome.blog/2019/03/13 ... shell-gui/
Or on github: https://github.com/falkobanaszak/veeam- ... idator-gui

PS: Please be aware of, that mapped network drives won't work as the command line tool itself does not support it. https://www.veeam.com/kb2086

I appreciate any kind of feedback for further developing that tool, either on my blog or here in the forums.

Thank you all and Best Regards !

Falko

Features to consider:

- Validating a single VM out of a backup file
- Validating a single VM out of a backup Job
- Validating a single VM out of a backup Job with date and time
VCP6.5-DCV, VCP6-DCV, VMCE, VMCA, Veeam Vanguard, VMware vExpert
https://www.virtualhome.blog
nielsengelen
Product Manager
Posts: 5797
Liked: 1215 times
Joined: Jul 15, 2013 11:09 am
Full Name: Niels Engelen
Contact:

Re: Veeam Backup Validator PowerShell GUI

Post by nielsengelen » 1 person likes this post

Thanks for sharing! I'm sure this will be useful for those who aren't familiar with the command line version.
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
pirx
Veteran
Posts: 599
Liked: 87 times
Joined: Dec 20, 2015 6:24 pm
Contact:

Re: Veeam Backup Validator PowerShell GUI

Post by pirx »

I guess there is no way to use the tool for a linux repository - other than somehow mounting the repo with sshfs or something similar?

This is not a problem of this tool, I don't see any way to sue Validator with linux out of the box. Do I miss something?
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Veeam Backup Validator PowerShell GUI

Post by oleg.feoktistov »

If you mean validating backups, which are on linux repository, I see no problem evaluating them with Validator itself, just not with Falko's interface as it supports only /file parameter. With Validator you should pass id of the backup on a linux repo to /backup parameter to make it work:

Code: Select all

$backup = Get-VBRBackup -Name 'Backup to Linux'
 .\Veeam.Backup.Validator.exe /backup:"$($backup.Id)" 
Thanks!
pirx
Veteran
Posts: 599
Liked: 87 times
Joined: Dec 20, 2015 6:24 pm
Contact:

Re: Veeam Backup Validator PowerShell GUI

Post by pirx »

Indeed this is working. I've no idea where I got the impression that it's not working with Linux repos. Thanks!
Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 5 guests