How to atomate & schedule Veeam.Backup.Validator.exe


Userlevel 7
Badge +2

Doc Veeam validator

KB2086: How to Use the Veeam Backup Validator

Veeam Backup Validator - Veeam Backup Guide for vSphere

 

It is essential to verify the status of the backups at the CRC level on the storage and the possibility of restoring them via Surebackup.

During the wizard for creating a backup job you can enable "Storage backup files healt check (detect and auto-heals corruption.

https://helpcenter.veeam.com/docs/backup/vsphere/backup_health_check.html?ver=110

I prefer to automate the validation process to have a detailed report every 2 weeks

  • Copy past and save .ps1 format

 

<#

.SYNOPSIS

    Performs a validation of all server backups

.DESCRIPTION  

.NOTES

    File Name      : veeam_validator.ps1

    Author         : Me and my colleague

    Prerequisite   : PowerShell V2 , VeeamPSSnapIn installed

#>

#------------------------------------------ VARIABLES TO CHANGE -------------------------

$email_infoTO = "yourmail@yourdomain.com"

$email_infoFrom = "$($env:COMPUTERNAME)@ yourdomain.com "

$email_infoServer = "your SMTP"

$SmtpPort = "25"

$emailUser = "your-veeam-srv@ yourdomain.com"

$emailPass = ""

$logfolder = "c:\temp"

$cliente = "your customer name"

#------------------------------------------ END VARIABLES-------------------------------

$Jobs = Get-VBRJob |where {$_.Jobtype -like "Backup"} | sort name

$OutputFile = "$logfolder\VeeamValidation.html"

Set-Location "C:\Program Files\Veeam\Backup and Replication\Backup\"

foreach ($Job in $Jobs) {

       $startdate = $(Get-Date -uformat %m-%d-%Y_%H:%M)

    $JobName = $Job.Name

       $JobName

       $tempFile = "$logfolder\Validation$jobname.html"

 

    if ($Job.IsRunning -eq $true) {

        Write-Host $JobName "is running" |ConvertTo-Html -Fragment | Out-File $tempFile

             $dateObject = [PSCustomObject]@{

             StartDate        = $startdate

             EndDate          = $(Get-Date -uformat %m-%d-%Y_%H:%M)}

             $dateObject |ConvertTo-Html -Fragment | Out-File $tempFile -append

        Continue

    }

       #Lunch validation

    & cmd /c "C:\Program Files\Veeam\Backup and Replication\Backup\Veeam.Backup.Validator.exe" /backup:"$JobName" /format:html /report:"$tempFile"

       #write start / end time

       $dateObject = [PSCustomObject]@{

       StartDate        = $startdate

       EndDate          = $(Get-Date -uformat %m-%d-%Y_%H:%M)}

       $dateObject |ConvertTo-Html -Fragment | Out-File $tempFile -append

}

Set-Location $logfolder

Get-ChildItem *.html|sort | Get-Content | Set-Content $OutputFile

$html = [string]$(Get-Content $OutputFile)

 

# Message stuff

$MessageSubject = "Live your best life now"

$Message = New-Object System.Net.Mail.MailMessage $email_infoFrom,$email_infoTO

$Message.IsBodyHTML = $true

$Message.Subject = "[$cliente] Backup Validation"

$Message.Body = $html

 

# Construct the SMTP client object, credentials, and send

$Smtp = New-Object Net.Mail.SmtpClient($email_infoServer,$SmtpPort)

$Smtp.EnableSsl = $false

$Smtp.Credentials = New-Object System.Net.NetworkCredential($emailUser,$emailPass)

$Smtp.Send($Message)

#send-mailmessage -SmtpServer $email_infoServer -to $email_infoTO -from $email_infoFrom -subject "[$cliente] Backup Validation" -body $html -BodyAsHtml -ErrorAction Stop

Get-ChildItem *.html |Remove-Item -Force

 

  • Create folder i c:\Script_Veeam
  • Open task Scheduler
  • Make sure you enter the correct path to the powershell executable Program/scipt:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

  • Add arguments (optional)

-file "C:\Script_Veeam\veeam_validator.ps1"


3 comments

Userlevel 7
Badge +2
  • Manual lunch from powershell ISE
  • HTML report like this :

let me know if there are any errors or typos. thanks to enjoy  :grinning:

Userlevel 7
Badge +6

Thank @Link State for sharing your script!

Do you know is there a technical difference between the validator you use in your script and the health check in job definition? I guess at least the report is more readable with your approach.

Userlevel 7
Badge +2

@vNote42 Do you mean these differences?

Veeam Backup Validator - Veeam Backup Guide for vSphere

Health Check for Backup Files - Veeam Backup Guide for vSphere

 

Comment