PowerShell script exchange
Post Reply
mb78
Novice
Posts: 4
Liked: never
Joined: Nov 11, 2020 11:07 pm
Full Name: matt b
Contact:

Powershell Help - List of all jobs and size of a full backup

Post by mb78 »

Hi All

We've got Veeam B&R 12.2.x and around 260 Backup Jobs (One VM per Job).

I need to get a report simply displaying the Backup Job Name and the size of a (or the most recent) full/synthetic backup.

This is part of a project to work out the size of new Synology we need so can start doing GFS offsite. All our jobs are 90 restore points (each job ran once per day) and a synthetic full made each Saturday.

I've seen script examples but don't do what we need exactly....

Is it possible to get some help with a script to display this information looping through each job - ideally dumped to CSV?

Thanks if can help...

M
oleg.feoktistov
Veeam Software
Posts: 2011
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Powershell Help - List of all jobs and size of a full backup

Post by oleg.feoktistov »

Hi,

Here is the sample script that could work in your case:

Code: Select all

$jobs = Get-VBRJob
$backups = Get-VBRBackup
foreach ($job in $jobs) {
    $backup = $backups | where {$_.JobId -eq $job.Id}
     if (!$backup) {
       continue
     }
    $rps = Get-VBRRestorePoint -Backup $backup | Sort-Object -Property CreationTime -Descending
    $storage = $rps[0].GetStorage()
    $backupSize = $storage.Stats.BackupSize
    $job | select Name, @{n='LastBackupSize';e={$backupSize}}

}
It fetches exactly the size of a last backup for each job. Keep in mind that it works only for image-level backups.

Best regards,
Oleg
mb78
Novice
Posts: 4
Liked: never
Joined: Nov 11, 2020 11:07 pm
Full Name: matt b
Contact:

Re: Powershell Help - List of all jobs and size of a full backup

Post by mb78 »

Thanks Oleg - appreciate the fast response.

This is perfect and gives me the size of the 'last backup' per job, but if running this mid-week, it gives the size of the incremental VIB file size.

Is there a way of getting the script to go back to the latest VBK file and report that size?

Thanks in advance
oleg.feoktistov
Veeam Software
Posts: 2011
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Powershell Help - List of all jobs and size of a full backup

Post by oleg.feoktistov »

Sure:

Code: Select all

$jobs = Get-VBRJob
$backups = Get-VBRBackup
foreach ($job in $jobs) {
    $backup = $backups | where {$_.JobId -eq $job.Id}
     if (!$backup) {
       continue
     }
    $rps = Get-VBRRestorePoint -Backup $backup | where {$_.Type -eq 'Full'} | Sort-Object -Property CreationTime -Descending
    $storage = $rps[0].GetStorage()
    $backupSize = $storage.Stats.BackupSize
    $job | select Name, @{n='LastFullSize';e={$backupSize}}

}
Keep in mind that it works as expected only if you have one VM per job. In case it's more than 1, you'll have the size of the latest full for the last VM processed, not for all of the VMs.

Best regards,
Oleg
Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests