PowerShell script exchange
Post Reply
rennieg
Lurker
Posts: 1
Liked: never
Joined: Dec 15, 2023 3:02 pm
Full Name: Geoff Rennie
Contact:

Report for Last Full Backup

Post by rennieg »

How do I generate a report that list only size of the last Full backup in the following format, doesnt need to be in this exact order but contains at least these below
Object Name Job Name Job Type Date/Time Duration Backup Server Total Backup Size

I need to know when the last full backup was done for each object (VM, Computer and so on) how long it took, the actual amount it backed up without compression or deduplication and which backup job the object is located in

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

Re: Report for Last Full Backup

Post by oleg.feoktistov »

Hi,

Try this code:

Code: Select all

$restorePoints = Get-VBRRestorePoint | Where-Object { $_.Type -eq "Full" } | Sort-Object -Property CreationTime -Descending
$lastFullBackups = $restorePoints | Group-Object -Property { $_.Name } | ForEach-Object { $_.Group | Select-Object -First 1 }
 
$jobs = Get-VBRJob
$fullBackupInfo = @()
foreach ($backup in $lastFullBackups) {
    $duration = $null
    $transferedSize = $null
    $storage = $backup.GetStorage()
    $backupSize = [Math]::Round($storage.Stats.BackupSize/1GB, 2)
    $job = $jobs | Where-Object { $_.GetObjectsInJob().ObjectId -eq $backup.ObjectId -and $backup.GetBackup().JobId -eq $_.Id }
    $session = Get-VBRBackupSession -Id $backup.JobRunId -ErrorAction SilentlyContinue
    if ($session) {
      $taskSession = $session.GetTaskSessions() | where {$_.ObjectId -eq $backup.ObjectId}
      $duration = $taskSession.Progress.Duration.ToString()
      $transferedSize = [Math]::Round($taskSession.Progress.TransferedSize/1GB, 2)
    }
    $fullBackupInfo += $backup | select @{n="Object Name";e={$backup.Name}}, `
                     @{n="Creation Time";e={$backup.CreationTime}}, `
                     @{n="Job Name";e={$job.Name}}, `
                     @{n="Job Type";e={$job.TypeToString}}, `
                     @{n="Duration";e={$duration}}, `
                     @{n="Transfered Size GB";e={$transferedSize}}, `
                     @{n="Backup Size GB";e={$backupSize}}
}
 
$fullBackupInfo
As for backup server info, you can fetch it with the cmdlet below:

Code: Select all

Get-VBRBackupServerInfo
Best regards,
Oleg
Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests