PowerShell script exchange
Post Reply
Kyrowire
Service Provider
Posts: 24
Liked: 3 times
Joined: Jul 29, 2014 9:40 am
Location: Auckland, New Zealand
Contact:

Validation Script

Post by Kyrowire »

Hi guys,

I need some help getting a validation script to run. Basically what I'm trying to achieve here is to import jobs from a repository, and then verify each job's .VBK file only.
I feel like I've got reasonably far with this with the little powershell knowledge I have but just can't work out how to pipe the CreationTime of the .vbk into the Veeam.backup.validator.exe

Here is what I've got so far:

Code: Select all

#Set the sending email address and destination address
$SenderAddr = "veeamverification@xyz.com"
$DestinationAddr = "alerts@xyz.com"

#Set the email server
$SMTPServer = "smtp.xyz.com"

#Scanning repository
Write-Host "Rescanning repository for new files"
Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue
set-location "C:\Program Files\Veeam\Backup and Replication\Backup"
Get-VBRBackupRepository -Name VeeamLTS | Sync-VBRBackupRepository

Write-Host "Check VBR Console and input any required encryption keys"

PAUSE

#Verifiying jobs
Write-Host "Verifying .VBK files for tape out"
$date = (Get-Date).AddDays(-1).ToString('dd-MM-yyyy')
$jobs = Get-VBRBackup
foreach ($job in $jobs)
{
$jobname = $job.name
$friendlyname = $job.metafilename
$jobdate = Get-VBRRestorePoint | ? {$_.type -eq "Full"} | select CreationTime

#This is to display the Job Names in the console for troubleshooting
write-output $jobname

#Set the Output file location
$VeeamOutputFile = "c:\Reports\Validation-$date-$friendlyname.html"

#Runs the exe file with the necessary parameters 
.\veeam.backup.validator.exe /backup:"$jobname" /date:"$jobdate" /format:html /report:"$VeeamOutputFile"

#Set the location of the output file
$JobFile = $VeeamOutputFile

#Sends the output files to a recipient
send-mailmessage -from "<$SenderAddr>" -to "<$DestinationAddr>" -subject "Veeam Validation Report for $jobname" -body "Report Attached." -Attachments "$JobFile" -priority High -dno onSuccess, onFailure -smtpServer $SMTPServer
}


#####################################
Any help appreciated!

Thanks.
nielsengelen
Product Manager
Posts: 5634
Liked: 1181 times
Joined: Jul 15, 2013 11:09 am
Full Name: Niels Engelen
Contact:

Re: Validation Script

Post by nielsengelen »

How about reading the folder for files matching .VBK and then run the validator? This way you don't have to worry about a job or something not being in the Veeam infrastructure anymore.

The timestamp we write into the file is the processing start time of the specific VM and is a bit harder to get via PowerShell.
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
veremin
Product Manager
Posts: 20282
Liked: 2257 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Validation Script

Post by veremin »

just can't work out how to pipe the CreationTime of the .vbk into the Veeam.backup.validator.exe
Can you elaborate on it a little bit? Do you want to validate only .vbks older than X days? Thanks.
Kyrowire
Service Provider
Posts: 24
Liked: 3 times
Joined: Jul 29, 2014 9:40 am
Location: Auckland, New Zealand
Contact:

Re: Validation Script

Post by Kyrowire »

vmniels wrote:How about reading the folder for files matching .VBK and then run the validator?
Yes I'd be happy to do that, I just can't work out how to get PowerShell/Validator to recursively look through folders and only validate .vbk files. I'm not good with PowerShell at all really.
Kyrowire
Service Provider
Posts: 24
Liked: 3 times
Joined: Jul 29, 2014 9:40 am
Location: Auckland, New Zealand
Contact:

Re: Validation Script

Post by Kyrowire »

v.Eremin wrote:Can you elaborate on it a little bit? Do you want to validate only .vbks older than X days? Thanks.
I only want to validate .vbk files. I was trying to use the CreationTime so I can tell the Veeam.backup.validator.exe to validate the file with a specific date (the .vbk). Otherwise the validator attempts to scan only the latest .vib file in the chain and in this case I have copied only the .vbk to a secondary location without the .vib's. (Basically to a staging repository, validating the files and then writing them off to tape).

I wish there was a switch for the validator to just validate .vbk's only :)
veremin
Product Manager
Posts: 20282
Liked: 2257 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Validation Script

Post by veremin »

I think what Niels was trying to recommend is to search the given directory (where the backups are located), using .vbk as a file mask and pass resulting data to validator tool as a /file parameter. Just a rough example:

Code: Select all

$VBK = Get-Item -Path "YourDirectory\*.vbk" 
$Path = $VBK.FullName
Validator.exe /file:$Path
Thanks.
Kyrowire
Service Provider
Posts: 24
Liked: 3 times
Joined: Jul 29, 2014 9:40 am
Location: Auckland, New Zealand
Contact:

Re: Validation Script

Post by Kyrowire »

Hi,

I'd love to do this but I think I have 2 things that prevent me from doing this:

1.) The backups are encrypted so need to be imported into the console and decrypted first.
2.) Secondly the files are located on a separate repository server and the Validator doesn't appear to work with UNC paths.

Hence why I've tried to import the jobs and then run the validator on the imported job, but trying to specify the full as the target.

Any other ideas?

Thanks.
veremin
Product Manager
Posts: 20282
Liked: 2257 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Validation Script

Post by veremin »

I'm still a little bit confused. If you need to confirm only .vbk files, why are you importing a backup job as a whole instead of importing only full backup files?

Sticking to that approach would make even the search query easier, as you would have to find only those jobs (backups) that have "imported" postfix in their names.

Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests