PowerShell script exchange
Post Reply
sandsturm
Veteran
Posts: 291
Liked: 25 times
Joined: Mar 23, 2015 8:30 am
Contact:

Get-VBRRestorePoint takes hours

Post by sandsturm »

I made a script to report the timestamp of the most current restorepoint and also the oldest available restorepoint. I get these restorepoints with the following command:

$all_restorePoints = Get-VBRRestorePoint | where-object {($_.Type -eq 'Full' -or $_.Type -eq 'Increment') -and $_.FindSourceJob().name -notmatch 'LAG_' -and $_.CreationTime -gt (get-date).AddDays(-90) } | Sort-Object -Property VMName,CreationTime

it takes about 4 hours to get all these restorepoints, currently i get about 38'000 restorepoints back from above command from about 25 backupjobs and about 500 VMs.

Is there a more efficient way to get the oldest and the newest restore point of all VMs?

thx
sandsturm
david.domask
Veeam Software
Posts: 2123
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Get-VBRRestorePoint takes hours

Post by david.domask »

Hi @sandsturm,

I think it's been discussed on some filter improvements for Get-VBRRestorePoint, but no information on if/when this comes.

Unfortunately you'll need to go to unsupported methods to speed this up. Note that such methods are not supported in any fashion and Veeam Support cannot assist with such methods.

Use the GetOibs() method on CBackup objects and try sorting by CreationDate.

Code: Select all

$backup = Get-VBRBackup -name 'name of backup'
$rps = $backup.GetOibs() | Sort -Property CreationTime
$newestpoints = $rps[-1]
$oldestpoints = $rps[0]
Results will be something like this:

Code: Select all

PS C:\> $backup.GetOibs() |sort -Property CreationTime

VM Name                   Creation Time          Type
-------                   -------------          ----
DDom-TinyVM_migrated      7/9/2022 09:43:45      Full
DDom-TinyVM_migrated      7/16/2022 09:43:16     Full
DDom-TinyVM_migrated      7/17/2022 09:43:06     Increment
DDom-TinyVM_migrated      7/18/2022 09:43:08     Increment
DDom-TinyVM_migrated      7/19/2022 09:43:01     Increment
DDom-TinyVM_migrated      7/20/2022 09:43:17     Increment
DDom-TinyVM_migrated      7/21/2022 09:43:15     Increment
DDom-TinyVM_migrated      7/22/2022 09:43:01     Increment
DDom-TinyVM_migrated      7/23/2022 09:43:23     Full
DDom-TinyVM_migrated      7/24/2022 09:43:12     Increment
DDom-TinyVM_migrated      7/25/2022 09:43:11     Increment
DDom-TinyVM_migrated      7/26/2022 09:42:58     Increment


PS C:\> $rps = $backup.GetOibs() | Sort -Property CreationTime
>> $newestpoints = $rps[-1]
>> $oldestpoints = $rps[0]
PS C:\> $newestpoints

VM Name                   Creation Time          Type
-------                   -------------          ----
DDom-TinyVM_migrated      7/26/2022 09:42:58     Increment


PS C:\> $oldestpoints

VM Name                   Creation Time          Type
-------                   -------------          ----
DDom-TinyVM_migrated      7/9/2022 09:43:45      Full
This is a job with a single machine, so with multiple machines, you'll need to add some filtering. You can use the Name property and sort -Unique, then just filter on that

Code: Select all

$machinenames = $rps.Name | Sort -Unique
foreach($n in $machinenames){
	$mrps = $rps |Where-Object {$_.Name -eq $n}
	[rest of the code]
I think just write a function for that last part to parse all the names.

I know that this is a bit of a workaround, but you should see it go a lot faster until there is some better filtering for Get-VBRRestorePoint
David Domask | Product Management: Principal Analyst
sandsturm
Veteran
Posts: 291
Liked: 25 times
Joined: Mar 23, 2015 8:30 am
Contact:

Re: Get-VBRRestorePoint takes hours

Post by sandsturm » 1 person likes this post

Hi David

Thanks a lot for this solution, i adopted it to my script and it works very well. My script is now 3-4 times faster in total.

thanks a lot!
sandsturm
david.domask
Veeam Software
Posts: 2123
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Get-VBRRestorePoint takes hours

Post by david.domask »

Wonderful! I'm glad it can work for you and that we had a great improvement.

The official cmdlet I believe is focused for improvements on filtering to speed it up a bit, but as I don't want to assume, let's ask @oleg.feoktistov the Product Manager that focuses on this. I think he's on holiday at the moment I'm writing, but when he's back maybe he can confirm if the filtering for Get-VBRRestorePoint is something for the future. If not at the moment, it's definitely a feature request from me :)
David Domask | Product Management: Principal Analyst
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Get-VBRRestorePoint takes hours

Post by oleg.feoktistov »

Hi,

4 hours to get 38000 restore points is tremendously long. This spring we had the discussion about the same issue with 18000 records being queried in 16 minutes and it was considered slow, let alone 4 hours.

Do you happen to have Get-VBRRestorePoint cmdlet implemented in a loop? Or is the line of code you shared the literal way you use it?

Also, using complex .NET methods in a filtering statement is not a good idea. Instead, try processing them separately.
For example:

Code: Select all

$rps = Get-vbrrestorepoint
$filtered = $rps | where-object {($_.Type -eq 'Full' -or $_.Type -eq 'Increment') -and $_.CreationTime -gt (get-date).AddDays(-90) } | Sort-Object -Property VMName,CreationTime
$filteredTotal = @()
foreach ($point in $filtered) {
  $sourceJob = $point.FindSourceJob()
  if ($sourceJob.Name -notmatch 'Job Name') {
    $filteredTotal += $point
  }
}
With just that I was able to cut the processing time in half.


Thanks,
Oleg
sandsturm
Veteran
Posts: 291
Liked: 25 times
Joined: Mar 23, 2015 8:30 am
Contact:

Re: Get-VBRRestorePoint takes hours

Post by sandsturm »

Hi Oleg

Thanks for your answer. I just ran the script today again and I needed 64 minutes to get back about 400k restorepoints (sorry, i mis spelled the number above, it was 380k) when I run:

$all_restorePoints = Get-VBRRestorePoint | where-object {($_.Type -eq 'Full' -or $_.Type -eq 'Increment') -and $_.FindSourceJob().name -notmatch 'LAG_' -and $_.CreationTime -gt (get-date).AddDays(-90) } | Sort-Object -Property VMName,CreationTime

I tried your version after that:
Get-VBRrestorepoint took 63 minutes
creating var $filtered took 25 minutes
foreach loop took 11 minutes

It seems that I'm not really faster with this method. Not sure completely why I have only about 1 hour today compared to 4 hours the last time I tried....

thx
sandsturm
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Get-VBRRestorePoint takes hours

Post by oleg.feoktistov »

Hi,

380k restore points is a lot, but weird the script above didn't optimize performance at all.
What if you try it other way around and get backups, which don't match specific name first? Since backup and job names correspond, you can just use regex directly on Backup.Name. For example:

Code: Select all

$backups = Get-VBRBackup | where {$_.Name -notmatch 'LAG_'}
foreach ($backup in $backups) {
  $rps = Get-VBRRestorePoint -Backup $backup
  $rps | where {($_.Type -eq 'Full' -or $_.Type -eq 'Increment') `
  -and $_.CreationTime -gt (get-date).AddDays(-90) } | sort -Property VMName,CreationTime
}

Thanks,
Oleg
Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests