PowerShell script exchange
Post Reply
wane
Enthusiast
Posts: 39
Liked: 6 times
Joined: Jun 26, 2020 9:47 pm
Full Name: Walter Neu
Contact:

Number of backups and total sum

Post by wane »

Hi all,
is there a possibility (Powershell, SQL, etc.) to find out the number of written backups and the size of the written backups as a total sum?
We need to provide a monthly overview of this for the management.

Many thanks for your help
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 669 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Number of backups and total sum

Post by oleg.feoktistov »

Hi Walter,

Sure, try this one:

Code: Select all

$backups = Get-VBRBackup | where {$_.VMCount -ne 0}
$sizeTotal = $null
foreach ($backup in $backups) {
  $storages = $backup.GetAllStorages()
  foreach ($storage in $storages) {
    $sizeTotal += $storage.Stats.BackupSize
  }
}

$sizeRounded = [Math]::Round($sizeTotal / 1GB, 1)

$sizeTotal | select @{n='BackupsCount';e={$backups.Count}}, @{n='TotalSizeGB';e={$sizeRounded}}
Please mind though that Get-VBRBackup doesn't show some types. For instance, snapshots or backup copies of backups made with Veeam for AWS/Azure/Google. If you want to retrieve those, you might need to use this .NET method instead:

Code: Select all

$backups = [Veeam.Backup.Core.CBackup]::GetAll()
If you have any VCB instances connected to your VBR console, make sure to exclude cloud backups made by those instances as they are not taking up any space in your VBR environment and has no size information to offer from VBR side. Example:

Code: Select all

$backups = [Veeam.Backup.Core.CBackup]::GetAll() | where {$_.TypeToString -ne 'AWS EC2'}
Thanks,
Oleg
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests