PowerShell script exchange
Post Reply
MaPf
Enthusiast
Posts: 30
Liked: 2 times
Joined: Apr 07, 2020 6:23 pm
Full Name: Markus Pfohl
Contact:

Get size of all tape backups

Post by MaPf »

Hello all,
for billing reasons I'd like to get the size of all tape sessions from specified jobs.
In the B&R GUI I can see the properties of "<job> on Tape" that lists all current tape Backups of a job ... cumulating the "Backup Size" of that output would be perfect.
Image

Is there a way to script that?

Thanks
Markus
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Get size of all tape backups

Post by oleg.feoktistov » 1 person likes this post

Hi Markus,

Sure there is. Here is an example:

Code: Select all


# This script shows total size of backup files in GB for each tape backup.
$jobType = [Veeam.Backup.Model.EDbJobType]::VmTapeBackup
$backups = [Veeam.Backup.Core.CBackup]::FindByJobType($true, $JobType)
foreach ($backup in $backups) {
    [int]$totalSize = ""
    $storages = $backup.GetAllStorages()
    foreach ($storage in $storages) {
        $backupSize = $storage.Stats.BackupSize/1GB
        $backupSize = [Convert]::ToInt32($backupSize)
        $totalSize += $backupSize
    }
   $restorepoints = Get-VBRRestorePoint -Backup $backup
   $backup | select-object Name, @{n='RPCount';e={$restorepoints.Count}}, @{n='BackupSizeTotal, GB';e={$totalSize}}
} 
Cheers,
Oleg
MaPf
Enthusiast
Posts: 30
Liked: 2 times
Joined: Apr 07, 2020 6:23 pm
Full Name: Markus Pfohl
Contact:

Re: Get size of all tape backups

Post by MaPf »

Hey Oleg,

that is one neat script, works great!
I just added "| Export-Csv d:\temp\tapesizes.csv -Append" in line 10 ... for better postprocessing.

Much appreciated
Thanks
Markus
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Get size of all tape backups

Post by oleg.feoktistov » 1 person likes this post

Hi Markus,

Sure thing, glad it helped! You might also want to slightly change the output format for backup size to avoid overly rounded values.

Best regards,
Oleg
vmtech123
Veeam Legend
Posts: 235
Liked: 134 times
Joined: Mar 28, 2019 2:01 pm
Full Name: SP
Contact:

Re: Get size of all tape backups

Post by vmtech123 »

Very Handy. Thanks
Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests