PowerShell script exchange
Post Reply
Markus.K1985
Veeam Vanguard
Posts: 86
Liked: 22 times
Joined: Dec 08, 2014 2:30 pm
Full Name: Markus Kraus
Contact:

Veeam Cloud Repository Disk Space Report

Post by Markus.K1985 »

Hello,

I am currently working on a problem that users of my PRTG-Sensor Script (https://github.com/mycloudrevolution/Ad ... RStats.ps1) reported.

I have forked the "Get-vPCRepoInfo" PowerShell function from Shawn (https://blog.smasterson.com/) into the script.

I liked the idea of the "SyncSpaceInfoToDb" Method to get the latest details of the repo. But as the Veeam Cloud Repositories became more popular, more and more users reported problems with the script. I have created a workaround that excluded Cloud Repositories from the script but in my opinion, this is not a proper solution. I have also seen some users on Shawn's blog reported this problem.

I am currently not sure where the problem is located, the "SyncSpaceInfoToDb" Method or the Space info in the Object itself ($r.info.CachedFreeSpace $r.Info.CachedTotalSpace). I do not have access to a cloud repository to dig deeper into the problem.

Is someone with Access to a cloud repo willing to support me in creating a proper solution?

The first step might be verifying that the Space info is available for Cloud Repos:

Code: Select all

[Array]$RepoList = Get-VBRBackupRepository | Where-Object {$_.Type -ne "SanSnapshotOnly"} 
[Array]$ScaleOuts = Get-VBRBackupRepository -ScaleOut
if ($ScaleOuts) {
    foreach ($ScaleOut in $ScaleOuts) {
        $Extents = Get-VBRRepositoryExtent -Repository $ScaleOut
        foreach ($Extent in $Extents) {
            $RepoList = $RepoList + $Extent.repository
        }
    }
}
$RepoList | Select-Object Name, @{Name="CachedTotalSpaceGB"; Expression= {[Math]::Round([Decimal]$_.info.CachedTotalSpace/1GB,2)}}, @{Name="CachedFreeSpaceGB"; Expression= {[Math]::Round([Decimal]$_.info.CachedFreeSpace/1GB,2)}} | Format-Table -AutoSize

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

Re: Veeam Cloud Repository Disk Space Report

Post by veremin »

May be you can share some light on what you're trying to achieve? Chances are there are easier way to reach the given goal. Thanks!

oleg.feoktistov
Veeam Software
Posts: 434
Liked: 136 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Veeam Cloud Repository Disk Space Report

Post by oleg.feoktistov » 1 person likes this post

Hi Markus,
I am currently not sure where the problem is located, the "SyncSpaceInfoToDb" Method or the Space info in the Object itself ($r.info.CachedFreeSpace $r.Info.CachedTotalSpace).
Neither Capacity extent object resolved with Get-VBRCapacityExtent, nor Object storage repositories object resolved with Get-VBRObjectStorageRepository has used space property or a method to get it.
As I see so far, the only size-related info on Cloud repositories/extents added to VBR that can be queried with Veeam Powershell snap-in is SizeLimit property you configured on Object Storage Repository addition/edition wizard:

Code: Select all

PS C:\Users\Admin> $repository = get-vbrobjectstoragerepository
PS C:\Users\Admin> $repository[0].SizeLimit
2048
For capacity extents:

Code: Select all

PS C:\Users\Admin> $repository = get-vbrbackuprepository -scaleout
PS C:\Users\Admin> $repository.CapacityExtent.Repository.SizeLimit
2048
If it comes to an object storage as a capacity tier extent usage information, you can leverage scale-out backup repositories report with its own cmdlet.

Another workaround I can think of is to get a name of your cloud repository and then pass it to the other cmdlets from cloud modules like Azure, AzureRm etc. to get the cloud repository size.

Meanwhile, we will discuss this missing property with our colleagues.

Thanks,
Oleg

chris.arceneaux
Veeam Software
Posts: 239
Liked: 120 times
Joined: Jun 24, 2019 1:39 pm
Full Name: Chris Arceneaux
Location: Kentucky, USA
Contact:

Re: Veeam Cloud Repository Disk Space Report

Post by chris.arceneaux »

@Markus.K1985 - Are you trying to determine disk space used for a SOBR Capacity extent, like Oleg mentioned, or are you trying to determine disk space used for a Cloud Repository (Cloud Connect repo)?

Markus.K1985
Veeam Vanguard
Posts: 86
Liked: 22 times
Joined: Dec 08, 2014 2:30 pm
Full Name: Markus Kraus
Contact:

Re: Veeam Cloud Repository Disk Space Report

Post by Markus.K1985 »

Hi,

the disk space query should be used for Veeam Cloud Connect Repositories ("Veeam.Backup.Core.CCloudRepository" PowerShell Object).

This PowerShell object does not have valid values for the info.CachedTotalSpace and info.CachedFreeSpace properties:

Code: Select all

CachedTotalSpace         : -1
CachedFreeSpace          : -1
Please see this GitHub Issue as reference:
https://github.com/mycloudrevolution/Ad ... /issues/42

chris.arceneaux
Veeam Software
Posts: 239
Liked: 120 times
Joined: Jun 24, 2019 1:39 pm
Full Name: Chris Arceneaux
Location: Kentucky, USA
Contact:

Re: Veeam Cloud Repository Disk Space Report

Post by chris.arceneaux » 2 people like this post

This should give you what you're looking for:

Code: Select all

# Gathering Service Providers
$providers = Get-VBRCloudProvider
# Gathering Cloud Repositories
$repos = Get-VBRBackupRepository | Where-Object {$_.Type -eq "Cloud"}

foreach ($provider in $providers){
    # Only process provider if backup resources have been allocated
    if ($provider.Resources){
        # In case multiple resources have been assigned
        foreach ($resource in $provider.Resources){
            $repo = $repos | Where-Object {($_.CloudProvider.HostName -eq $provider.DNSName) -and ($_.Name -eq $resource.RepositoryName)}
            $totalSpaceGb = [Math]::Round([Decimal]$resource.RepositoryAllocatedSpace/1KB,2)
            $totalUsedGb = [Math]::Round([Decimal]([Veeam.Backup.Core.CBackupRepository]::GetRepositoryStoragesSize($repo.Id.Guid))/1GB,2)
            Write-Output "Service Provider: $($provider.DNSName)"
            Write-Output "Repository Name: $($resource.RepositoryName)"
            Write-Output "Total Space GB: $totalSpaceGb"
            Write-Output "Totale Used GB: $totalUsedGb"
        }
    }
}

Markus.K1985
Veeam Vanguard
Posts: 86
Liked: 22 times
Joined: Dec 08, 2014 2:30 pm
Full Name: Markus Kraus
Contact:

Re: Veeam Cloud Repository Disk Space Report

Post by Markus.K1985 »

Doesn't look like I could've figured it out myself.

chris.arceneaux
Veeam Software
Posts: 239
Liked: 120 times
Joined: Jun 24, 2019 1:39 pm
Full Name: Chris Arceneaux
Location: Kentucky, USA
Contact:

Re: Veeam Cloud Repository Disk Space Report

Post by chris.arceneaux »

Hi Markus,

I agree that I had to do a little digging to find the solution I presented. I've opened up a FR internally about this so that we can get a clearer method of pulling these numbers in a future Veeam release.

Markus.K1985
Veeam Vanguard
Posts: 86
Liked: 22 times
Joined: Dec 08, 2014 2:30 pm
Full Name: Markus Kraus
Contact:

Re: Veeam Cloud Repository Disk Space Report

Post by Markus.K1985 »

I was able to verify your solution successfully. Thanks!

chris.arceneaux
Veeam Software
Posts: 239
Liked: 120 times
Joined: Jun 24, 2019 1:39 pm
Full Name: Chris Arceneaux
Location: Kentucky, USA
Contact:

Re: Veeam Cloud Repository Disk Space Report

Post by chris.arceneaux »

Good to hear! Thanks for letting everyone know.

mbaghdadi
Lurker
Posts: 1
Liked: never
Joined: Jan 10, 2020 3:28 am
Full Name: Mustapha Baghdadi
Contact:

Re: Veeam Cloud Repository Disk Space Report

Post by mbaghdadi »

Hi Gents,

thanks for the details over this issue, i am having the same problem with the cloud repo aswell, but when i run the provided script the used space for some weird reason wouldnt show the correct capacity.

i have a cloud repo that has 29.3TB total capacity, used space of 24.7TB, for some reason this used space keeps showing 80.44TB within veeam console until i rescan it manually it will show used space of 24.7TB then within minutes it goes back to 80TB for some reason!!!!

running the script above i picking up always the used space as 80.44TB!!
any idea what is the problem here???

chris.arceneaux
Veeam Software
Posts: 239
Liked: 120 times
Joined: Jun 24, 2019 1:39 pm
Full Name: Chris Arceneaux
Location: Kentucky, USA
Contact:

Re: Veeam Cloud Repository Disk Space Report

Post by chris.arceneaux »

Welcome to the Veeam forums Mustapha!

I recommend you work with your Service Provider or open a case with Veeam support as that doesn't sound like expected behavior.

Markus.K1985
Veeam Vanguard
Posts: 86
Liked: 22 times
Joined: Dec 08, 2014 2:30 pm
Full Name: Markus Kraus
Contact:

Re: Veeam Cloud Repository Disk Space Report

Post by Markus.K1985 »

Hi Chris,

have you already used the provided Code Snippet with Veeam v10?

The method

Code: Select all

[Veeam.Backup.Core.CBackupRepository]::GetRepositoryStoragesSize($CloudRepos.Id.Guid)
does not work any more.

See also: powershell-f26/veeam-10-getrepositoryst ... 65281.html

Do you have another Idea on how to gather the Cloud Repo usage via PowerShell?

chris.arceneaux
Veeam Software
Posts: 239
Liked: 120 times
Joined: Jun 24, 2019 1:39 pm
Full Name: Chris Arceneaux
Location: Kentucky, USA
Contact:

Re: Veeam Cloud Repository Disk Space Report

Post by chris.arceneaux » 1 person likes this post

Hi Markus,

Looks like you've already found your answer. The undocumented call I referenced previously has been renamed to:

Code: Select all

[Veeam.Backup.Core.CBackupRepository]::GetRepositoryBackupsSize($CloudRepos.Id.Guid)
Image

Image

The only other method I know of also involves using undocumented API calls and requires more steps. As such, I recommend this method.

PeterStam
Novice
Posts: 8
Liked: never
Joined: Feb 25, 2015 1:49 pm
Full Name: Peter Stam
Contact:

[MERGED] Used Space Azure Capacity Extent, where is it?

Post by PeterStam »

Hi There,
I can't seem to find the Used Space of an Azure Blob capacity extent, I do get the 'sizelimit' from the Get-VBRCapacityExtent cmdlet...but wheren is the used space?
Regards,
Peter

Vitaliy S.
Product Manager
Posts: 24075
Liked: 1807 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Veeam Cloud Repository Disk Space Report

Post by Vitaliy S. »

Hi, I don't think there is a quick way to report on this (at least I couldn't find it), but I'm merging your question to the existing thread that should be useful. Also, summoning our PS expert @oleg.feoktistov for assistance :)

oleg.feoktistov
Veeam Software
Posts: 434
Liked: 136 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Veeam Cloud Repository Disk Space Report

Post by oleg.feoktistov »

Vitaliy, your spell has worked :wink:
@PeterStam, this property is missing in .NET classes on the backend, so we cannot retrieve it for object storage other than from the UI.
Though, I keep it in my mind and also in my files as a feature request.
Thanks!

PeterStam
Novice
Posts: 8
Liked: never
Joined: Feb 25, 2015 1:49 pm
Full Name: Peter Stam
Contact:

Re: Veeam Cloud Repository Disk Space Report

Post by PeterStam »

Hello Oleg,
Ok thank you, but how do u retrieve it in the UI then? is it a call to a SQL table? When a rescan happens it is updated somehow....
Regards

oleg.feoktistov
Veeam Software
Posts: 434
Liked: 136 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Veeam Cloud Repository Disk Space Report

Post by oleg.feoktistov »

Exactly. Weirdly enough, approaches of retrieving it from SQL database differ depending on object storage type.
For Azure Blob and S3-Compatible used_space property is directly kept here:

Code: Select all

 [dbo].[BackupRepositories.LimitSettings] 
Whereas for Amazon S3 it is calculated from total_space and free_space properties kept here:

Code: Select all

[dbo].[BackupRepositories]
So, to parse used_space for my Azure Blob I'd use something like that:

Code: Select all

$repos = Get-VBRObjectStorageRepository | where {$_.Type -eq 'AzureBlob'}
$creds = Get-Credential
$query = "SELECT * FROM [dbo].[BackupRepositories.LimitSettings]"
$query = Invoke-Sqlcmd -ServerInstance "InstanceName" -Database "DatabaseName" -Credential $creds -Query $query
foreach ($object in $query) {
    foreach ($repo in $repos) {
    if ($object.repository_id -eq $repo.Id) {
    	$repo | select Name, @{n='UsedSpace';e={$object.used_space}}
    }
  }
} 
I also found an interesting static method for that, which didn't work against Amazon S3 :D :

Code: Select all

$objectRepo = Get-VBRObjectStorageRepository | where {$_.Type -eq 'AzureBlob'}
$size = [Veeam.Backup.Core.CBackupRepository]::CalcArchiveRepositoryUsedSizeByIndices($objectRepo.Id)
I guess, eventually, adding it as official PS type property should save some time.

Hope that helps,
Oleg

PeterStam
Novice
Posts: 8
Liked: never
Joined: Feb 25, 2015 1:49 pm
Full Name: Peter Stam
Contact:

Re: Veeam Cloud Repository Disk Space Report

Post by PeterStam »

Hello Oleg,
That static method seems to work for AzureBlob, thanks
Regards,
Peter

Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests