PowerShell script exchange
Post Reply
cheezoid
Novice
Posts: 4
Liked: never
Joined: Apr 19, 2023 5:58 am
Contact:

Obtaining backup copy last backup size

Post by cheezoid »

Hi there

I'm trying to obtain the last backup size of backup and backup copy jobs. Using the method below I'm able to retrieve a size for a backup but not he corresponding backup copy job. This is true for all copy jobs. They all report complete/successful and have a size in the console.

Code: Select all

PS C:\> $backup = Get-VBRBackup -Name server_bu_copy
PS C:\> $backup.FindLastFullUncorruptedStorage()
PS C:\> $backup.FindLastFullUncorruptedStorage().stats
PS C:\> $backup = Get-VBRBackup -Name server
PS C:\> $backup.FindLastFullUncorruptedStorage().stats

 BackupSize     DataSize DedupRatio CompressRatio
 ----------     -------- ---------- -------------
46259077120 137438995313         68            49
Similarly, when using this script below which I found in the forums, it returns the desired result for backups but not backup copies.

Code: Select all

# Get a list of the scheduled jobs
$Jobs = Get-VBRJob | ?{$_.IsScheduleEnabled -eq "True"} | Sort Name

# Now create the VM report
ForEach ($Job in $Jobs) {
   $VMReport += Get-VBRTaskSession $Job.FindLastSession() | Select-Object Name ,JobName ,Status,
   @{Name="StartTime"; Expression = {$_.Progress.StartTimeLocal}},
   @{Name="StopTime"; Expression = {$_.Progress.StopTimeLocal}},
   @{Name="Duration"; Expression = {'{0:00}:{1:00}:{2:00}' -f $_.Progress.Duration.Hours, $_.Progress.Duration.Minutes, $_.Progress.Duration.Seconds}},
   @{Name="SizeGB"; Expression = {[math]::Round(($_.Progress.ProcessedSize/1GB),3)}},
   @{Name="UsedGB"; Expression = {[math]::Round(($_.Progress.ProcessedUsedSize/1GB),3)}},
   @{Name="ReadGB"; Expression = {[math]::Round(($_.Progress.ReadSize/1GB),3)}},
   @{Name="TransferedGB"; Expression = {[math]::Round(($_.Progress.TransferedSize/1GB),3)}},
   @{N="Busy";E={($_.Logger.GetLog().updatedrecords.title | where {$_ -like "Busy*"}) -replace 'Busy: Source', 'Src' -replace 'Network', 'Net' -Replace 'Target', 'Tar' -Replace 'Proxy', 'Prx'}},
   @{N="Used Proxy";E={($_.Logger.GetLog().updatedrecords.title | where {$_ -like "Using backup proxy*"}) -replace 'Using backup proxy ','' -replace 'for disk Hard','-'}}
   }
Any ideas how this can be achieved?

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

Re: Obtaining backup copy last backup size

Post by oleg.feoktistov » 1 person likes this post

Hi,

For backup copy jobs stats try to get child backups first:

Code: Select all

$backup = Get-VBRBackup -Name server
$childBackup = $backup.FindChildBackups()
$childBackup.FindLastFullUncorruptedStorage().stats
Best regards,
Oleg
cheezoid
Novice
Posts: 4
Liked: never
Joined: Apr 19, 2023 5:58 am
Contact:

Re: Obtaining backup copy last backup size

Post by cheezoid »

Great, that did the trick, thanks :)
cheezoid
Novice
Posts: 4
Liked: never
Joined: Apr 19, 2023 5:58 am
Contact:

Re: Obtaining backup copy last backup size

Post by cheezoid »

While this worked for v11 it doesn't work for v12.
It seems this method is no longer present FindLastFullUncorruptedStorage()
How might I obtain these stats in v12?

Code: Select all

Method invocation failed because [Veeam.Backup.Core.CBackup] does not contain a method named 'FindLastFullUncorruptedStorage'.
At line:5 char:1
+ $childBackup.FindLastFullUncorruptedStorage().stats
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Obtaining backup copy last backup size

Post by oleg.feoktistov »

Hi,

If you want to get only uncorrupted storages, you need to get oibs first and then filter them out:

Code: Select all

$backup = Get-VBRBackup -Name 'Backup Copy Job 1'
$childBackups = $backup.FindChildBackups()
$oibs = Get-VBRRestorePoint -Backup $childBackups
foreach ($oib in $oibs) {
  if ($oib.IsCorrupted -eq $false) {
  $uncorruptedStorages = $oib.FindStorage()
  $uncorruptedStorages
  }
}
If you want to get all storages, you can use this method:

Code: Select all

$backup = Get-VBRBackup -Name 'Backup Copy Job 1'
$childBackups = $backup.FindChildBackups()
$childBackups.GetAllChildrenStorages()
Thanks,
Oleg
cheezoid
Novice
Posts: 4
Liked: never
Joined: Apr 19, 2023 5:58 am
Contact:

Re: Obtaining backup copy last backup size

Post by cheezoid »

Looks good, thanks :)
Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests