PowerShell script exchange
Post Reply
mellema
Novice
Posts: 5
Liked: 2 times
Joined: Aug 31, 2022 7:41 pm
Contact:

Get-VBRApplicationRestorePoint issue

Post by mellema » 1 person likes this post

I've created a Powershell script to restore a production database to another server, but I have an issue when using the Get-VBRApplicationRestorePoint cmdlet.

When running this command:

Code: Select all

Get-VBRApplicationRestorePoint -SQL -Name "SERVERNAME" | Sort-Object -Property CreationTime -Descending
The output of the three first objects are:

Code: Select all

IsExchange        : False
IsActiveDirectory : False
IsSharePoint      : False
IsSQL             : True
IsOracle          : False
IsPostgreSQL      : False
CreationTime      : 4/22/2024 1:31:15 AM
Type              : Increment
IsIndexed         : False
IsCorrupted       : False
Name              : SERVERNAME
Id                : 6b0a2c66-3007-4120-8947-80aebb4472f0

IsExchange        : False
IsActiveDirectory : False
IsSharePoint      : False
IsSQL             : True
IsOracle          : False
IsPostgreSQL      : False
CreationTime      : 4/22/2024 1:31:15 AM
Type              : Increment
IsIndexed         : False
IsCorrupted       : False
Name              : SERVERNAME
Id                : 6a218d0d-475b-4ced-a469-3104b84a92ec

IsExchange        : False
IsActiveDirectory : False
IsSharePoint      : False
IsSQL             : True
IsOracle          : False
IsPostgreSQL      : False
CreationTime      : 4/22/2024 1:31:15 AM
Type              : Increment
IsIndexed         : False
IsCorrupted       : False
Name              : SERVERNAME
Id                : b54d09b8-08a4-459c-855e-deb3ee966912
I have an on premise backup and two off premise backups in object storage. Since all three have the same creation time, I have no good way of determining what repository the backup is stored on. If the script chooses the latest one listed with a | Select-Object -First 1 appended to the end, it can choose to try and run the restore from the off premise object storage. The speed difference in the restore from the object storage compared to on premise is ten-fold slower. From the GUI this is not an issue as the restore is initiated straight from the on premise repository.

Is there a way to select a VBRApplicationRestorePoint from a specific repository with Veeam Powershell cmdlets? If not, can I query the Veeam database for information possibly not available in Powershell?
david.domask
Veeam Software
Posts: 2153
Liked: 517 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Get-VBRApplicationRestorePoint issue

Post by david.domask » 1 person likes this post

Hi mellema,

Indeed, I think it would be good if there was some property from these to indicate which are on Capacity Tier; I'll note the request internally.

As a workaround, regrettably we would need to use unsupported methods, but this should work.

Code: Select all

$appRPs = Get-VBRApplicationRestorePoint
$rps = @()
Foreach($a in $appsRPs){
	$RPs += Get-VBRRestorePoint -id $a.id
}
$LocalRps = $rps | Where-Object {$_.GetChainStorages().IsContentInternal -eq $true}
$localAppRps = $appRPs | Where-Object {$localRps.id -contains $_.id}
$LocalAppRps will have your local restore application restore point objects, and you can then be sure you're only picking from local storages.
David Domask | Product Management: Principal Analyst
tina.cornelison
Novice
Posts: 8
Liked: 1 time
Joined: Mar 31, 2022 7:47 pm
Full Name: Tina Cornelison
Contact:

Re: Get-VBRApplicationRestorePoint issue

Post by tina.cornelison »

Different type of restorepoint. I used this to export out the latest restore points to chose from. May not work for your automation. But all the examples I find from Veeam always assume you want "Select-Object -First 1" and that's not always the case.

Code: Select all

$restorePoint = $null
$restorePoint = Get-VBRRestorePoint -name $VM | select CreationTime, uid 
Write-Host "VM Name: $($vm), Last Restore Point: $($restorePoint.CreationTime)"
if ($restorePoint -eq $null -or $restorePoint -eq "") 
{
	write-host "no backup found"
	$OutputRow = @{
					col1 = $vm
					col2 = "not found"
}
$outputfile = New-Object PSObject -Property $OutputRow
$outputfile | Export-Csv -Delimiter "," 'c:\nt\code\veeam_uid.csv' -Encoding "utf8" -NoTypeInformation
$outputfile = @()

}else {
	Write-Host "VM Name: $($vm), Last Restore Point: $($restorePoint.CreationTime)"
	$restorePoint | Export-Csv -Path 'c:\nt\code\veeam_uid.csv'-NoTypeInformation
}
mellema
Novice
Posts: 5
Liked: 2 times
Joined: Aug 31, 2022 7:41 pm
Contact:

Re: Get-VBRApplicationRestorePoint issue

Post by mellema »

Unfortunately the copies reside on standard "Backup Repositories" and not "External Repositories" so the $_.GetChainStorages().IsContentInternal condition is true for all on premise and cloud copies (storage is configured outside of Veeam in Azure and Amazon S3). I'm not able to find a usable property from anything listed in $_.GetChainStorages() . Are there any other properties to view on Application Restore Points via Powershell? If not, Does the VBR database have the information we can query with SQL?
david.domask wrote: Apr 30, 2024 11:13 am Hi mellema,

Indeed, I think it would be good if there was some property from these to indicate which are on Capacity Tier; I'll note the request internally.

As a workaround, regrettably we would need to use unsupported methods, but this should work.

Code: Select all

$appRPs = Get-VBRApplicationRestorePoint
$rps = @()
Foreach($a in $appsRPs){
	$RPs += Get-VBRRestorePoint -id $a.id
}
$LocalRps = $rps | Where-Object {$_.GetChainStorages().IsContentInternal -eq $true}
$localAppRps = $appRPs | Where-Object {$localRps.id -contains $_.id}
$LocalAppRps will have your local restore application restore point objects, and you can then be sure you're only picking from local storages.
mellema
Novice
Posts: 5
Liked: 2 times
Joined: Aug 31, 2022 7:41 pm
Contact:

Re: Get-VBRApplicationRestorePoint issue

Post by mellema »

Actually close to a solution using the values from $rps.getchainstorages().HostID

That looks to match HostId for get-vbrbackuprepository to the repository I'm attempting to restore from. Thanks for the code snippet to led me to this.

PS. This would be really helpful to select the repository natively using Get-VBRApplicationRestorePoint I do hope the internal note leads to it getting added to a future release.
mellema
Novice
Posts: 5
Liked: 2 times
Joined: Aug 31, 2022 7:41 pm
Contact:

Re: Get-VBRApplicationRestorePoint issue

Post by mellema » 1 person likes this post

My testing went well and will be attempting use in production soon. Here's was what I was able to put together once I knew how to pull hostID and ID from the various other Veeam PS commands:

Code: Select all

$MYSQLREPO = Get-VBRBackupRepository -Name "ONPREMISREPONAME"
$appsRPs = Get-VBrRApplicationRestorePoint -SQL -Name "SQLSERVER01"  | Sort-Object -Property CreationTime -Descending | Select-Object -First 3
$rps = @()
Foreach($a in $appsRPs){
	$rps += Get-VBRRestorePoint -id $a.id
}
$LocalRps = $rps | Where-Object {$_.GetChainStorages().HostID -eq $MYSQLREPO.hostid}
$SQLrestorepoint = Get-VBRApplicationRestorePoint -Id $localrps.Id
david.domask
Veeam Software
Posts: 2153
Liked: 517 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Get-VBRApplicationRestorePoint issue

Post by david.domask »

Hi mellema,

Thank you very much for sharing your resulting script and I'm glad to hear you were able to find a solution. I'm actually not sure that this part:

> so the $_.GetChainStorages().IsContentInternal condition is true for all on premise and cloud copies (storage is configured outside of Veeam in Azure and Amazon S3).

Is completely accurate but I may be working with old information so for now let's continue with your method -- the hostID value is sensible to use and should work for your needs here.
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests