PowerShell script exchange
Post Reply
ATIhelpdesk
Influencer
Posts: 11
Liked: 2 times
Joined: Oct 07, 2015 12:28 pm
Full Name: ATI Helpdesk
Contact:

Veeam 10 [Veeam.Backup.Core.CbackupRepository]::GetRepositoryStoragesSize($repo.Id)

Post by ATIhelpdesk »

On Veeam 9.5 I used [Veeam.Backup.Core.CbackupRepository]::GetRepositoryStoragesSize($repo.Id) to get the repository used space--which I need for a billing script I've written in Powershell. After updating to Veeam 10, it appears GetRepositoryStoragesSize is no longer a member of Veeam.Backup.Core.CbackupRepository. Anyone know how to get the USED SPACE column value from the Backup Repositories page using Powershell?
jhoughes
Veeam Vanguard
Posts: 282
Liked: 113 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Veeam 10 [Veeam.Backup.Core.CbackupRepository]::GetRepositoryStoragesSize($repo.Id)

Post by jhoughes »

It's now container under the Info property. Example for my repo titled 'ReFs-PerVM'

Code: Select all

$repo = Get-VBRBackupRepository -Name ReFS-PerVM

$repo.Info.CachedFreeSpace / 1GB
171.453430175781

$repo.Info.CachedTotalSpace / 1TB
1.17169189453125
GUI for comparison:
Image
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
ATIhelpdesk
Influencer
Posts: 11
Liked: 2 times
Joined: Oct 07, 2015 12:28 pm
Full Name: ATI Helpdesk
Contact:

Re: Veeam 10 [Veeam.Backup.Core.CbackupRepository]::GetRepositoryStoragesSize($repo.Id)

Post by ATIhelpdesk »

jhoughes,

Thank you. Alas, subtracting those two values does not give you the USED SPACE column value from the BACKUP INFRASTRUCTURE/Backup Repositories page in the B&R Console. Subtracting those two does give you the amount of space used on the repository storage device. USED SPACE is the amount of space that would be used on a storage device if you restored all of the backed up entities stored in the repository--which is what my billing department wants.
jhoughes
Veeam Vanguard
Posts: 282
Liked: 113 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Veeam 10 [Veeam.Backup.Core.CbackupRepository]::GetRepositoryStoragesSize($repo.Id)

Post by jhoughes » 1 person likes this post

Apologies, my draft got posted by accident while I switched to another task.

The free & capacity space details are now contained under the Info property. Example for my repo titled 'ReFs-PerVM':

Code: Select all


$repo = Get-VBRBackupRepository -Name ReFS-PerVM

$repo.Info.CachedFreeSpace / 1GB
171.453430175781

$repo.Info.CachedTotalSpace / 1TB
1.17169189453125
GUI for comparison:
Image

To get the Used Space size, we have to do some calculation on the backup size of the storage files. This can take a while depending on the size of your repository and backup chains.

Code: Select all

$repo = Get-VBRBackupRepository -Name ReFS-PerVM
$backups = $repo.GetBackups()
$storages = $backups.GetAllStorages()
($storages.stats | Measure-Object -Property backupsize -sum | Select -ExpandProperty Sum) /1TB
1.48376941680908
This returns a bit less than the GUI due to rounding.
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
ATIhelpdesk
Influencer
Posts: 11
Liked: 2 times
Joined: Oct 07, 2015 12:28 pm
Full Name: ATI Helpdesk
Contact:

Re: Veeam 10 [Veeam.Backup.Core.CbackupRepository]::GetRepositoryStoragesSize($repo.Id)

Post by ATIhelpdesk » 1 person likes this post

jhoughes,

Thank you very much. That does indeed return the value I need. Your quick reply gets some pressure off me, which I do not need.
jhoughes
Veeam Vanguard
Posts: 282
Liked: 113 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Veeam 10 [Veeam.Backup.Core.CbackupRepository]::GetRepositoryStoragesSize($repo.Id)

Post by jhoughes » 1 person likes this post

Sounds good, I'm glad that it helps you out.
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
ATIhelpdesk
Influencer
Posts: 11
Liked: 2 times
Joined: Oct 07, 2015 12:28 pm
Full Name: ATI Helpdesk
Contact:

Re: Veeam 10 [Veeam.Backup.Core.CbackupRepository]::GetRepositoryStoragesSize($repo.Id)

Post by ATIhelpdesk »

While not a problem for me right now, this method does not appear to work with scale-out repositories. Neither the repository nor the extents have a GetBackup() method. I will work on that later but, however, if someone has a quick answer, I would be appreciative.
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Veeam 10 [Veeam.Backup.Core.CbackupRepository]::GetRepositoryStoragesSize($repo.Id)

Post by veremin »

If I remember correctly, Extent object should contain a Repository as a parameter. So, you should be able to access underlying repository as well as its method GetBackups method.

$Extent.Repository.GetBackups()

Thanks!
ATIhelpdesk
Influencer
Posts: 11
Liked: 2 times
Joined: Oct 07, 2015 12:28 pm
Full Name: ATI Helpdesk
Contact:

Re: Veeam 10 [Veeam.Backup.Core.CbackupRepository]::GetRepositoryStoragesSize($repo.Id)

Post by ATIhelpdesk » 1 person likes this post

veremin,

Thank you. I tried your method and; It did not return an error but, it also did not return any records.

Here it the method I figured out:
# Get a list of all backups and select only those whose repository name matches the scale-out repo I want ( $r )
# Notice it is using the GetRepositoryName() method in the Where clause ( sometimes I love Powershell )
$backups = Get-VBRBackup | Where-Object {$_.GetRepositoryName() -eq $r}
# get all the storage records used by the backups
$storages = $backups.GetAllStorages()
# sum the storage records backupsize property
# unlike jhoughes, I am returning the number in bytes. it is divided by 1Tb later in the script
$uspace = $storages.stats | Measure-Object -Property backupsize -sum | Select -ExpandProperty Sum

Thanks to everyone for the help
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Veeam 10 [Veeam.Backup.Core.CbackupRepository]::GetRepositoryStoragesSize($repo.Id)

Post by veremin »

Yeah, I figured that as well, then, either your script or the one provided Joe (that uses CachedFreeSpace values) should be a way to go. Thanks!
thjor
Service Provider
Posts: 11
Liked: 3 times
Joined: Apr 19, 2018 8:01 am
Contact:

Re: Veeam 10 [Veeam.Backup.Core.CbackupRepository]::GetRepositoryStoragesSize($repo.Id)

Post by thjor » 2 people like this post

Hi all

I found that this worked for me and give the same results as in the console.

[Veeam.Backup.Core.CBackupRepository]::GetRepositoryBackupsSize($repository.Id.Guid)
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Veeam 10 [Veeam.Backup.Core.CbackupRepository]::GetRepositoryStoragesSize($repo.Id)

Post by veremin » 1 person likes this post

Happy to hear you've found the different approach, and even happier that you've shared it with the community; much appreciated!
cferilli
Influencer
Posts: 13
Liked: 5 times
Joined: Mar 21, 2017 3:51 pm
Full Name: cferilli
Contact:

Re: Veeam 10 [Veeam.Backup.Core.CbackupRepository]::GetRepositoryStoragesSize($repo.Id)

Post by cferilli » 1 person likes this post

Very interesting topic, I was searching for a similar solution, now I got it :D

Thanks to all !
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests