PowerShell script exchange
MaPf
Enthusiast
Posts: 37 Liked: 3 times
Joined: Apr 07, 2020 6:23 pm
Full Name: Markus Pfohl
Contact:
Post
by MaPf » May 11, 2020 9:25 am
this post
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.
Is there a way to script that?
Thanks
Markus
oleg.feoktistov
Veeam Software
Posts: 2025 Liked: 674 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:
Post
by oleg.feoktistov » May 11, 2020 5:24 pm
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: 37 Liked: 3 times
Joined: Apr 07, 2020 6:23 pm
Full Name: Markus Pfohl
Contact:
Post
by MaPf » May 11, 2020 8:01 pm
this post
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: 2025 Liked: 674 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:
Post
by oleg.feoktistov » May 12, 2020 1:13 pm
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: 265 Liked: 141 times
Joined: Mar 28, 2019 2:01 pm
Full Name: SP
Contact:
Post
by vmtech123 » Jun 14, 2022 4:08 pm
this post
Very Handy. Thanks
Users browsing this forum: No registered users and 3 guests