Validation Script

PowerShell script exchange

Validation Script

Veeam Logoby Kyrowire » Tue Apr 26, 2016 5:14 am

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.
Kyrowire
Service Provider
 
Posts: 23
Liked: 3 times
Joined: Tue Jul 29, 2014 9:40 am
Location: Auckland, New Zealand

Re: Validation Script

Veeam Logoby vmniels » Tue Apr 26, 2016 9:38 am

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.
VCP-DCV
Veeam Certified Engineer
http://foonet.be
vmniels
Veeam Software
 
Posts: 1511
Liked: 325 times
Joined: Mon Jul 15, 2013 11:09 am
Full Name: Niels Engelen

Re: Validation Script

Veeam Logoby v.Eremin » Tue Apr 26, 2016 10:23 am

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.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 969 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Validation Script

Veeam Logoby Kyrowire » Tue Apr 26, 2016 7:51 pm

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: 23
Liked: 3 times
Joined: Tue Jul 29, 2014 9:40 am
Location: Auckland, New Zealand

Re: Validation Script

Veeam Logoby Kyrowire » Tue Apr 26, 2016 7:55 pm

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 :)
Kyrowire
Service Provider
 
Posts: 23
Liked: 3 times
Joined: Tue Jul 29, 2014 9:40 am
Location: Auckland, New Zealand

Re: Validation Script

Veeam Logoby v.Eremin » Wed Apr 27, 2016 9:42 am

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.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 969 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Validation Script

Veeam Logoby Kyrowire » Sun May 01, 2016 11:12 pm

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.
Kyrowire
Service Provider
 
Posts: 23
Liked: 3 times
Joined: Tue Jul 29, 2014 9:40 am
Location: Auckland, New Zealand

Re: Validation Script

Veeam Logoby v.Eremin » Mon May 02, 2016 11:26 am

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.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 969 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 8 guests