PowerShell script exchange
Post Reply
rjv1971
Enthusiast
Posts: 29
Liked: never
Joined: Apr 12, 2017 6:21 pm
Full Name: Ron
Location: Columbus
Contact:

Script to get the size of GFS backups on a SOBR, split by Weekly/Monthly/Yearly

Post by rjv1971 »

Veeam 12.1 user. I can go into the Veeam B&R server, click on the 'Backups' section, select a backup copy job and do a right-click and select properties. What I see in the popup Window is a list of all backups Veeam has. Fields are: (server) NAME, Data Size, Backup Size, Date, Retention.

What I would like to have is a powershell script, that would iterate through all my backup copy jobs, and list all available restorepoints that have a Yearly retention, with their size. I am looking through the PowerShell reference guide but cannot really find any command(s) that would achieve this.

I did (from these forums) find this cmdlet/script, but it doesn't work for SOBR:

(Get-VBRBackup | Get-VBRRestorePoint) |Select-Object vmname, @{N="Job"; E={$_.getsourcejob().name }}, @{N="Repo"; E={$_.getrepository().Type }} , @{N="size"; E={$_.getstorage().stats.BackupSize }}

If I change Get-VBRBackup with Get-VBRLegacyBackupCopySourceJob it returns nothing.

Has anyone done this before? Can anyone point me in the right direction?

Edit: The whole reason for doing this is that we might be switching capacity-tier cloud providers. I am asked to find the space taken by all of our yearly backups stored with our current cloud provider and figure out what the egress fees would be to move to the new cloud-storage provider.
david.domask
Veeam Software
Posts: 1425
Liked: 365 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Script to get the size of GFS backups on a SOBR, split by Weekly/Monthly/Yearly

Post by david.domask »

Hi Ron,

Just to confirm, we're checking the performance tier, correct?

post509821.html#p509821

This script should still work, though you will need to edit it within the ForEach loop to include the property for the actual storage (backup file) size from the $Storages array.

Try working through that script line by line first and once you populate $Storages, check the object properties on one of the objects in the array and you will see the Stats property which tracks the file size.

Give it a shot with the script and see if it meets your needs. Basically it adds a function, and you can just collect all your Backup Copy backups into an array, then look over the array with that function.
David Domask | Product Management: Principal Analyst
rjv1971
Enthusiast
Posts: 29
Liked: never
Joined: Apr 12, 2017 6:21 pm
Full Name: Ron
Location: Columbus
Contact:

Re: Script to get the size of GFS backups on a SOBR, split by Weekly/Monthly/Yearly

Post by rjv1971 »

Axctually, Capacity tier. I'd like to know how much space the weekly/monthly/yearly backups take 'in the cloud'
oleg.feoktistov
Veeam Software
Posts: 1953
Liked: 645 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Script to get the size of GFS backups on a SOBR, split by Weekly/Monthly/Yearly

Post by oleg.feoktistov » 2 people like this post

Hi Ron,

Try this script. Replace SOBR and backup names with custom:

Code: Select all

$repo = Get-VBRBackupRepository -Name 'SOBR-01' -ScaleOut
$backup = Get-VBRSOBRObjectStorageBackup -CapacityTier -Name 'vSphere to SOBR' | where {$_.RepositoryId -eq $repo.Id}
$rps = Get-VBRSOBRObjectStorageRestorePoint -Backup $backup
foreach ($rp in $rps) {
  $storage = [Veeam.Backup.Core.CStorage]::FindByOibId($rp.Id)
  $storage | where {$_.GFSPeriod -eq 'Yearly' -or $_.GFSPeriod -eq 'Monthly' -or $_.GFSPeriod -eq 'Weekly' } `
  | select FilePath, @{n='BackupSizeGB';e={[Math]::Round($storage.Stats.BackupSize/1GB, 2)}}, GFSPeriod
}
Get-VBRSOBRObjectStorageBackup and Get-VBRSOBRObjectStorageRestorePoint are the cmdlets we added in 12.1 as a workaround solution to specifically cover getting backups on Capacity and Archive tiers because of their distinct architecture.

Best regards,
Oleg
rjv1971
Enthusiast
Posts: 29
Liked: never
Joined: Apr 12, 2017 6:21 pm
Full Name: Ron
Location: Columbus
Contact:

Re: Script to get the size of GFS backups on a SOBR, split by Weekly/Monthly/Yearly

Post by rjv1971 »

Thanks. I believe the $._Period in the "$storage | where {$_.Period -eq 'Yearly'" statement should be GfsPeriod? Then it gets back sizes.
oleg.feoktistov
Veeam Software
Posts: 1953
Liked: 645 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Script to get the size of GFS backups on a SOBR, split by Weekly/Monthly/Yearly

Post by oleg.feoktistov »

Yes, $_.Period should be $_.GFSPeriod. Apologies, my mistake. Fixed the script above. Thanks!
rjv1971
Enthusiast
Posts: 29
Liked: never
Joined: Apr 12, 2017 6:21 pm
Full Name: Ron
Location: Columbus
Contact:

Re: Script to get the size of GFS backups on a SOBR, split by Weekly/Monthly/Yearly

Post by rjv1971 »

One small addition. There's also backups that are marked with 2 retentions, eg. Weekly, Monthly and Monthly,Yearly, I updated the script like this to get those:

Code: Select all

$storage | where {$_.GfsPeriod -eq 'Yearly' -or $_.GfsPeriod -eq 'Monthly' -or $_.GfsPeriod -eq 'Weekly'  -or $_.GfsPeriod -eq 'Monthly, Yearly' -or $_.GfsPeriod -eq 'Weekly, Monthly'} `
  | select FilePath, @{n='BackupSizeGB';e={[Math]::Round($storage.Stats.BackupSize/1GB, 2)}}, GFSPeriod
  
oleg.feoktistov
Veeam Software
Posts: 1953
Liked: 645 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Script to get the size of GFS backups on a SOBR, split by Weekly/Monthly/Yearly

Post by oleg.feoktistov »

Good stuff, thanks Ron!
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests