Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $AgentJobs = Get-VBRComputerBackupJob
- foreach ($Job in $AgentJobs) {
- $Job.Name
- # -------------- GET AGENT JOB LAST SESSION ---------------------------
- # CREATE A VARIABLE IDENTIFYING IF THE JOB IS A POLICY OR NOT
- $IsPolicy = $False
- if ($Job.Mode -eq 'ManagedByAgent') { $IsPolicy = $True }
- "is it policy: $IsPolicy"
- # NOT ALL POLICY SESSIONS ARE BACKUPS, LOT OF CONFIG UPDATES THERE
- # TO FILTER IT TO JUST ACTUAL BACKUPS THE NAME HAS WILDCARDS ADDED
- # https://forums.veeam.com/post434804.html
- $JobNameForQuery = $Job.Name
- if ($IsPolicy) { $JobNameForQuery = '{0}?*' -f $Job.Name }
- $Sessions = Get-VBRComputerBackupJobSession -Name $JobNameForQuery
- $LastSession = $Sessions[0]
- $LastSessionTasks = Get-VBRTaskSession -Session $LastSession
- # -------------- GET AGENT JOB ID, NAME, TYPE ---------------------
- $JOB_ID = $Job.Id
- $JOB_NAME = $Job.Name
- if ($IsPolicy) {
- $JOB_TYPE = 'EpAgentPolicy'
- } else {
- $JOB_TYPE = 'EpAgentBackup'
- }
- $DATA_SIZE = 0
- $DATA_SIZE
- foreach ($Task in $LastSessionTasks) {
- $Task.info.ObjectName
- $DATA_SIZE += $Task.Progress.TotalUsedSize
- }
- $DATA_SIZE
- $Job.BackupType
- #$LastSession.CreationTime.Date
- $DATA_SIZE = 0
- foreach ($Task in $LastSessionTasks) {
- $DATA_SIZE += $Task.Progress.TotalUsedSize
- }
- $DATA_SIZE = 0
- foreach ($Task in $LastSessionTasks) {
- $DATA_SIZE += $Task.Progress.TotalUsedSize
- }
- if ($Job.BackupType -eq 'SelectedFiles') {
- $AgentBackup = Get-VBRBackup -Name $Job.Name
- $RestorePoints = Get-VBRRestorePoint -Backup $AgentBackup | `
- Sort-Object -Property CreationTimeUtc -Descending
- $RestorePointsOnlyFull = $RestorePoints | ? {$_.IsFull}
- if ($RestorePointsOnlyFull.count -gt 0) {
- $RestorePointsOnlyFull[0].CreationTime.DateTime
- $Storage = $RestorePointsOnlyFull[0].FindStorage()
- $VbkSize = $Storage.Stats.BackupSize
- $dedup = ($Storage.Stats.DedupRatio) / 100
- $compres = ($Storage.Stats.CompressRatio) / 100
- if ($dedup -eq 0) { $dedup = 1}
- if ($compres -eq 0) { $compres = 1}
- $DATA_SIZE = [int64]($VbkSize / $dedup / $compres)
- }
- }
- $DATA_SIZE
- "------------------"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement