PowerShell script exchange
Post Reply
woifgaung
Veeam Software
Posts: 79
Liked: 22 times
Joined: Oct 15, 2015 2:57 pm
Full Name: Wolfgang Scheer
Contact:

Query SOBR extent for restore point

Post by woifgaung »

In a script I need to know the exact SOBR extent of a specific restore point. When I analyzed how to get this information within a PowerShell script, I ended up with an SQL statement:

Code: Select all

$SOR = Get-VBRBackupRepository -name repo_name -ScaleOut | Get-VBRRepositoryExtent
$extent = (Invoke-Sqlcmd -Query "SELECT [dependant_repo_id] FROM [VeeamBackup].[dbo].[Backup.ExtRepo.Storages] WHERE [storage_id] = '$($d.StorageId)';" -ServerInstance "sql_server_Instance").dependant_repo_id
$base = ($SOR | ? {$_.id -eq $extent}).Repository.FriendlyPath
This worked at least in VBR 9.5. In v10 or v11 column dependant_repo_id seems to be removed. So my script does not work any more. Is there another/better way to get the extent of a restore point? I found the FindChainRepositories()-method. But it returns all extents of the chain.
Wolfgang | CEMEA Solutions Architect | vnote42.net
soncscy
Veteran
Posts: 643
Liked: 312 times
Joined: Aug 04, 2019 2:57 pm
Full Name: Harvey
Contact:

Re: Query SOBR extent for restore point

Post by soncscy »

Hey Wolfgang,

Parse on your storages as they have a method:

v10: FindExtentRepo(storage id)
v11: FindRepositoryForExistingStorage(storage id)

Should be much easier.
woifgaung
Veeam Software
Posts: 79
Liked: 22 times
Joined: Oct 15, 2015 2:57 pm
Full Name: Wolfgang Scheer
Contact:

Re: Query SOBR extent for restore point

Post by woifgaung »

Thanks that works! Had to change some logic of my script, but it works.
Interesting for my: why are these methods not available with the object you get with Get-VBRBackupRepository -ScaleOut?
Wolfgang | CEMEA Solutions Architect | vnote42.net
soncscy
Veteran
Posts: 643
Liked: 312 times
Joined: Aug 04, 2019 2:57 pm
Full Name: Harvey
Contact:

Re: Query SOBR extent for restore point

Post by soncscy »

Glad I could help!

To answer your question, it's because the methods are on CStorage objects, not on VBRScaleOutBackupRepository objects. The object returned by the actual cmdlet is fairly limited compared to CExtendableRepository objects (as best I can tell they're the same) and my guess is that the Get-VBRBackupRepository -Scaleout cmdlet is part of Veeam's attempt to "clean up" the exposed internal methods a bit.

I would just parse on the CStorage objects frankly speaking; you can get a full CExtendableRepository object by getting a backup targeted to a Scale Out Repository and using the GetRepository() method. The resulting object has some "interesting" methods, but this process might not be available in the future! So tread lightly ;)
woifgaung
Veeam Software
Posts: 79
Liked: 22 times
Joined: Oct 15, 2015 2:57 pm
Full Name: Wolfgang Scheer
Contact:

Re: Query SOBR extent for restore point

Post by woifgaung »

Now I need the backup job and restore-points before I query the SOBR. Pre-v10 I could start with the SOBR - which was very useful for my use case.
Thanks for all the information!
Wolfgang | CEMEA Solutions Architect | vnote42.net
soncscy
Veteran
Posts: 643
Liked: 312 times
Joined: Aug 04, 2019 2:57 pm
Full Name: Harvey
Contact:

Re: Query SOBR extent for restore point

Post by soncscy »

Sure, any time!

Maybe you can explain your script's workflow though a bit more; I suggested these methods because your script already queries the database on the storage.id value. What are you trying to to do with the script? Maybe there's a better way.
woifgaung
Veeam Software
Posts: 79
Liked: 22 times
Joined: Oct 15, 2015 2:57 pm
Full Name: Wolfgang Scheer
Contact:

Re: Query SOBR extent for restore point

Post by woifgaung »

I want to list all backup files (with absolute path to) on a SOBR. This is for finding orphaned backup files.
Wolfgang | CEMEA Solutions Architect | vnote42.net
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Query SOBR extent for restore point

Post by oleg.feoktistov »

Hi,

For SOBR repositories try this script:

Code: Select all

$backup = Get-VBRBackup -Name 'Backup to SOBR'
$rps = Get-VBRRestorePoint -Backup $backup
foreach ($rp in $rps) {
  $storage = $rp.FindStorage()
  $extent = $rp.FindChainRepositories()
  if ($extent.Type -eq 'LinuxLocal') {
  $rp | select Name, @{n='FullPath';e={"$($extent.FriendlyPath)/$($backup.PartialPath)/$($storage.PartialPath)"}}
  }
  else {
  $rp | select Name, @{n='FullPath';e={"$($extent.FriendlyPath)\$($backup.PartialPath)/$($storage.PartialPath)"}}
  }
}
I used a conditional flow for convenience to correctly construct paths in case a repository is of linux type.

Thanks,
Oleg
Post Reply

Who is online

Users browsing this forum: justin.hendren and 11 guests