PowerShell script exchange
edirschedl
Enthusiast
Posts: 44
Liked: 4 times
Joined: Jul 21, 2016 12:29 pm
Full Name: Emanuel Dirschedl
Contact:

Get all used backup repositories of a backup job

Post by edirschedl »

Hi,

we have some big scale-out repositories with a lot of extends.
With help of a script, I want to get all used extends of a single backup job. So for example I've a job called "Backup 1" and it has backup files on "Extend 1", "Extend 2" and "Extend 3" in a Scale-Out-Repo with 10 extends total.
How do I get this information on which extends there are backup files of this specific backup job - with help of a powershell script?


Thank you for your tips / advices.

Emanuel
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get all used backup repositories of a backup job

Post by veremin »

Backup object (Get-VBRBackup) contains identifier of repository it resides on ($Backup.info.RepositoryId).

If my assumption is correct and this property provides identifier of extent, not of Scale-Out Backup Repository as a whole, you should be able to find needed extent, using it. (VBRRepositoryExtent)
edirschedl
Enthusiast
Posts: 44
Liked: 4 times
Joined: Jul 21, 2016 12:29 pm
Full Name: Emanuel Dirschedl
Contact:

Re: Get all used backup repositories of a backup job

Post by edirschedl »

Sadly RepositoryID is the same ID as the Scale-Repo itself (or ParentID from the single extents). So that's no information to get the specific extents where the backup files are located.
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get all used backup repositories of a backup job

Post by veremin » 1 person likes this post

I do not have a good lab at hand to test the script, but at least it should give you the right directions:

Code: Select all

Asnp VeeamPssnapin
$Backup = (Get-VBRBackup | where {$_.Jobname -eq "Name of job pointed to SOBR"}) 
$Backup.GetOibs() | select name, {$_.FindChainRepositories().name}
Thanks.
edirschedl
Enthusiast
Posts: 44
Liked: 4 times
Joined: Jul 21, 2016 12:29 pm
Full Name: Emanuel Dirschedl
Contact:

Re: Get all used backup repositories of a backup job

Post by edirschedl »

Thank you very much! It works without problems now.
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get all used backup repositories of a backup job

Post by veremin »

You're welcome, if you want to get more smooth output, you can enhance the script further:

Code: Select all

Asnp VeeamPssnapin
$Backup = (Get-VBRBackup | where {$_.Jobname -eq "Name of job pointed to SOBR"}) 
$Backup.GetOibs() | select @{N="Name";E={$_.Name}}, @{N="Repository Name";E={$_.FindChainRepositories().name}} | ft -AutoSize 
Anyway, glad to hear my input was helpful. Let us know, should other questions arise.

Thanks.
keith.sng
Veeam Software
Posts: 46
Liked: never
Joined: Jan 16, 2017 8:47 am
Full Name: Keith Sng Chee Keong
Contact:

[MERGED] Get all used backup repositories of a backup job

Post by keith.sng »

Dear all,

Would like to know if someone can advise on how to generate out all the Backup Jobs listing within a Scale-Out Backup Repository using Powershell Scripts?

As this can be seen via the GUI but a customer is performing some migration and powershell output will be a much easier way to view ...

default scripts of:
Get-VBRRepositoryExtent -Repository "Name of Scale-Out" only returns the extents

Thanks in advance...
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get all used backup repositories of a backup job

Post by veremin »

Using script above, you can get all backups stored on particular SOBR along with names of extents those backups reside on. Is that something you're looking for?
keith.sng
Veeam Software
Posts: 46
Liked: never
Joined: Jan 16, 2017 8:47 am
Full Name: Keith Sng Chee Keong
Contact:

Re: Get all used backup repositories of a backup job

Post by keith.sng »

Hi,

For this, we have to specify the Backup Job Name which is rather tedious as our customer has a quite a large number of Jobs in place.

Ray has assisted and contributed to the following scripts..

Code: Select all

$Backup = (Get-VBRBackup | where {$_.Jobname -like "*"})
Foreach($Backup in $Backup) { 
$Job = Get-VBRJob -name $Backup.JobName
$Backup.GetOibs() | select name, {$_.FindChainRepositories().name}, {$Backup.JobName},{(Get-VBRBackupRepository -ScaleOut | Where {$_.Id -eq $Job.Info.TargetRepositoryId}).Name}
}
HCJ III
Lurker
Posts: 1
Liked: never
Joined: Mar 20, 2018 8:54 pm
Full Name: Harry C. Johnson
Contact:

[MERGED] Get All Jobs From SOBR

Post by HCJ III »

Previously I could use the Veeam Powershell snap-in to run a for each loop on Get-VBRBackupRepository and then call method getBackups() to return all Backup Jobs and their attributes like JobName, etc. for each Repository .

But SOBR Repositories do not return with Get-VBRBackupRepository.

They do Return with Get-VBRBackupRepository -Scaleout but the getBackups() methods is not available for Scaleout.

Is anyone aware of a method similar to getBackups() that will return Backup Job information for SOBR repositories (i.e. Get-VBRBackupRepository -Scaleout)?

Thanks in advance.
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get all used backup repositories of a backup job

Post by veremin »

Kindly, check the scripts provided above; should be exactly what you're looking for. Thanks.
tdewin
Veeam Software
Posts: 1818
Liked: 655 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: Get all used backup repositories of a backup job

Post by tdewin » 1 person likes this post

FYI if anybody needs this for getting Full paths. A lot of wild stuff here so I wouldn't deem it very reliable :)

Code: Select all

$sobrjob = Get-VBRJob -name "lin-sobr"
$linsobr = [Veeam.Backup.Core.CBackup]::GetAllByJob($sobrjob.Id)
$realsobr = $linsobr.GetRepository()
$svc = [Veeam.Backup.Core.CStorageToExtentAssociationService]::new()

$linstorages = @($linsobr.GetAllStorages())
$paths = @()
foreach($st in $linstorages) {
    $ext = $realsobr.FindExtentRepo($st.Id,$svc)
    $paths += New-Object -TypeName psobject -Property @{ext=$ext.Name;path=$($ext.Path.ToString(),$sobrjob.Name,$st.filepath -join "\")}
}
$paths
output

Code: Select all

ext    path                                            
---    ----                                            
sobr02 F:\sobr02\lin-sobr\lin1.30D2018-04-30T142340.vib
sobr01 F:\sobr01\lin-sobr\lin1.30D2018-04-30T142128.vbk
ThierryF
Expert
Posts: 129
Liked: 34 times
Joined: Mar 31, 2018 10:20 am
Contact:

[MERGED] [Scale Out] Repository Content ...

Post by ThierryF »

I recently discovered using GetBackup() function from Get-VBRBackupRepository,
I could grab stored object in the repository.

Sample :

PS> $BkpRepo=Get-VBRBackupRepository -Name "Repository_E_TEMP_BACKUPS_ONLY"
PS> $BkpRepo.GetBackups()


Info : Veeam.Backup.Model.CBackupInfo
Id : 14eab0e5-997b-4a7b-8bcd-0dacfad68e4d
OriginalId : 14eab0e5-997b-4a7b-8bcd-0dacfad68e4d
JobName : Test_Replication
Name : Test_Replication
Path : Test_Replication
CreationTime : 17/07/2018 09:44:53
LastPointCreationTime : 17/07/2018 09:45:29
VmCount : 1
JobTargetHostId : 89ac4eee-0520-4ba2-82fe-faa7d72ce511
JobTargetHostProtocol : Nfc
JobType : Replica
JobSourceType : VDDK
BackupPlatform : EVmware
JobTargetType : SnapReplica
(...)

Unfortunately, I cannot grab same info for scale-out backup repositories.
I can grab scale-out backup repository extents using
Get-VBRRepositoryExtent -Repository "Scale-out Backup Repository" for sample
but nor using scale-out repo name nor using extent names, I cannot retrieve infos
from getbackup() to get same above info.

PS C:\Users\adm> $BkpRepo=Get-VBRBackupRepository -ScaleOut -Name "Scale-out Backup Repository"
PS C:\Users\adm> foreach ($extent in $BkpRepo.Extent) { write-host "Rep Name ", $ext.Repository.name; $extent.Repository.GetBackups() }

Any trick I miss ?

Thanks

TH
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get all used backup repositories of a backup job

Post by veremin »

Check the last script provided by Timothy; should be exactly what you're after. Thanks.
ThierryF
Expert
Posts: 129
Liked: 34 times
Joined: Mar 31, 2018 10:20 am
Contact:

Re: Get all used backup repositories of a backup job

Post by ThierryF »

Cool, thanks !

TH
tgillispie
Technology Partner
Posts: 18
Liked: 5 times
Joined: Nov 16, 2010 10:52 pm
Full Name: Tom Gillipsie
Contact:

Re: Get all used backup repositories of a backup job

Post by tgillispie »

Running 9.5U4 Beta 2 - the following does not work. Did the "model" change? Is there an equivalent way to do this mapping (need to find info about each backup by SOBR extent).

$svc = [Veeam.Backup.Core.CStorageToExtentAssociationService]::new()

Code: Select all

Unable to find type [Veeam.Backup.Core.CStorageToExtentAssociationService]: make sure that the assembly containing this type is loaded.
At line:1 char:62
+ $svc = [Veeam.Backup.Core.CStorageToExtentAssociationService] <<<< ::new()
    + CategoryInfo          : InvalidOperation: (Veeam.Backup.Co...ociationService:String) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get all used backup repositories of a backup job

Post by veremin »

1) Typically PowerShell is unstable in beta releases, as it's the last thing that gets tested
2) You're using internal methods (not recommended practice). Structure of those methods and properties might change between product releases, which will result in script failure.

Thanks!
tgillispie
Technology Partner
Posts: 18
Liked: 5 times
Joined: Nov 16, 2010 10:52 pm
Full Name: Tom Gillipsie
Contact:

Re: Get all used backup repositories of a backup job

Post by tgillispie »

Undersood.

Will there be a way in 9.5 U4 to get this mapping between storages and extents? So far I have found no way to get the details of what backups are on a SOBR extent, such as total size (could iterate over backups if there was a way to do so), total size of fulls, incrementals, etc.

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

Re: Get all used backup repositories of a backup job

Post by veremin »

Will know for sure, once GA build is available - as there will be zero chances that internal object structure will be changed :) Thanks!
Vek17
Service Provider
Posts: 49
Liked: 15 times
Joined: May 29, 2018 8:42 pm
Contact:

Re: Get all used backup repositories of a backup job

Post by Vek17 »

Based on current build the new way to do so is:

Code: Select all

$Extent = $SoBR.FindExtentRepo($Storage.Id)

instead of:

Code: Select all

$Extent = $SoBR.FindExtentRepo($Storage.Id, [Veeam.Backup.Core.CStorageToExtentAssociationService])
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get all used backup repositories of a backup job

Post by veremin »

Then, you can safely stick to this approach, as nothing will be changed from RTM build in terms of PS cmdlets, objects and their structure. Thanks!
mdiver
Veeam Legend
Posts: 230
Liked: 37 times
Joined: Nov 04, 2009 2:08 pm
Contact:

Re: Get all used backup repositories of a backup job

Post by mdiver »

Unfortunately Timothy's code doesn't seem to work any more in V10. Does anyone have a working approad?

Thanks,
Mike
tdewin wrote: Apr 30, 2018 2:54 pm FYI if anybody needs this for getting Full paths. A lot of wild stuff here so I wouldn't deem it very reliable :)

Code: Select all

$sobrjob = Get-VBRJob -name "lin-sobr"
$linsobr = [Veeam.Backup.Core.CBackup]::GetAllByJob($sobrjob.Id)
$realsobr = $linsobr.GetRepository()
$svc = [Veeam.Backup.Core.CStorageToExtentAssociationService]::new()

$linstorages = @($linsobr.GetAllStorages())
$paths = @()
foreach($st in $linstorages) {
    $ext = $realsobr.FindExtentRepo($st.Id,$svc)
    $paths += New-Object -TypeName psobject -Property @{ext=$ext.Name;path=$($ext.Path.ToString(),$sobrjob.Name,$st.filepath -join "\")}
}
$paths
output

Code: Select all

ext    path                                            
---    ----                                            
sobr02 F:\sobr02\lin-sobr\lin1.30D2018-04-30T142340.vib
sobr01 F:\sobr01\lin-sobr\lin1.30D2018-04-30T142128.vbk
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Get all used backup repositories of a backup job

Post by oleg.feoktistov » 1 person likes this post

Hi Mike,

First, CStorageToExtentAssociationService class is deprecated. So, remove the line below:

Code: Select all

$svc = [Veeam.Backup.Core.CStorageToExtentAssociationService]::new()
Then, pass storage id as the only argument to FindExtentRepo() method accordingly:

Code: Select all

$ext = $realsobr.FindExtentRepo($st.Id)
And you are good to go.

Cheers!
Oleg
mdiver
Veeam Legend
Posts: 230
Liked: 37 times
Joined: Nov 04, 2009 2:08 pm
Contact:

Re: Get all used backup repositories of a backup job

Post by mdiver »

Works like a charm! Thanks Oleg, for your ultra fast help.

The output of this script should actually be available as a VeeamONE report or alike.
Very helpful e.g. when you run into a "partial fast clone" for large ReFS SOBRs.

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

Re: Get all used backup repositories of a backup job

Post by oleg.feoktistov »

Sure thing, glad to help!
The output of this script should actually be available as a VeeamONE report or alike.
Very helpful e.g. when you run into a "partial fast clone" for large ReFS SOBRs.
Veeam ONE expert @Vitaliy S. to the rescue.
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Get all used backup repositories of a backup job

Post by Vitaliy S. »

@mdiver, can you please clarify the use case for this information? How would you use it if you had this report in Veeam ONE?
mdiver
Veeam Legend
Posts: 230
Liked: 37 times
Joined: Nov 04, 2009 2:08 pm
Contact:

Re: Get all used backup repositories of a backup job

Post by mdiver »

Hi Vitaly.

We quite often see a misalignment in the ReFS SOBRs leading to a "partial fast clone".
Also with SOBRs of heterogeneous extent sizes I had the situation of under-utilization of extents.
In the VBR GUI it's quite hard to determine the distribution of the files to be able to manually correct things.
I would appreciate e.g. report showing the non-fulfilment of a certain placement policy.
If you e.g. set the policy to data locality and VBR decides to split the files to different repos a report could flag the alarm.

Thanks,
Mike
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Get all used backup repositories of a backup job

Post by Vitaliy S. »

Hi Mike,

Ok, thanks for sharing the details! Can you please also tell me what you will do with this data? Will you initiate some internal processes or just contact Veeam support to understand what's going on? Just want to understand if this report is aimed for troubleshooting mostly or also solves other use cases.

Thanks!
mdiver
Veeam Legend
Posts: 230
Liked: 37 times
Joined: Nov 04, 2009 2:08 pm
Contact:

Re: Get all used backup repositories of a backup job

Post by mdiver »

Hi Vitaliy.

Just stumbled upon your response. Sorry for the delay.
I thought maybe of rearranging some files followed by a rescan.
It happens once in a while that files end up on wrong extents - even though data-locality is on.

Regards,
Mike
wishr
Veteran
Posts: 3077
Liked: 455 times
Joined: Aug 07, 2018 3:11 pm
Full Name: Fedor Maslov
Contact:

Re: Get all used backup repositories of a backup job

Post by wishr »

Hi Mdiver,

Fedor from VONE team here. I've logged a feature request for that capability.

Thanks
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests