PowerShell script exchange
Post Reply
btm
Novice
Posts: 4
Liked: never
Joined: Sep 16, 2020 12:04 pm
Contact:

Find size of data written to tape by tape job

Post by btm »

I would like to know how to get the information about how much data was transferred to tape.

Especially, I'm interested in this information:
https://i.imgur.com/UB4CGqv.png

I cannot find it in the Session I found with this command:

Code: Select all

$tapeSessions = (Get-VBRsession -job (Get-VBRTapejob | Select-Object -last 1)) | Where-Object {$_.CreationTime -ge (Get-Date).AddHours(-36)}
My current work-around is adding the size from all backups together, like so:

Code: Select all

$total_size = 0	
$backupJobNames = $tapeJob.object.name
ForEach ($backupJobName  in $backupJobNames)
{
	$total_size += (Get-VBRJob -Name $backupJobName).Info.IncludedSize
}
But that doesn't show me when there was no data transferred.
btm
Novice
Posts: 4
Liked: never
Joined: Sep 16, 2020 12:04 pm
Contact:

Re: Find size of data written to tape by tape job

Post by btm »

I found this impressive script:
https://blog.smasterson.com/2017/12/22/ ... ort-9-5-3/

With the relevant code here:

Code: Select all

      $arrAllSessTp = $sessListTp | Sort Creationtime | Select @{Name="Job Name"; Expression = {$_.Name}},
        @{Name="State"; Expression = {$_.State}},
        @{Name="Start Time"; Expression = {$_.CreationTime}},
        @{Name="Stop Time"; Expression = {If ($_.EndTime -eq "1/1/1900 12:00:00 AM"){"-"} Else {$_.EndTime}}},
        @{Name="Duration (HH:MM:SS)"; Expression = {Get-Duration -ts $_.Progress.Duration}},                    
        @{Name="Avg Speed (MB/s)"; Expression = {[Math]::Round($_.Info.Progress.AvgSpeed/1MB,2)}},
        @{Name="Total (GB)"; Expression = {[Math]::Round($_.Info.Progress.ProcessedSize/1GB,2)}},
        @{Name="Data Read (GB)"; Expression = {[Math]::Round($_.Info.Progress.ReadSize/1GB,2)}},
        @{Name="Transferred (GB)"; Expression = {[Math]::Round($_.Info.Progress.TransferedSize/1GB,2)}},                    
        @{Name="Details"; Expression = {($_.GetDetails()).Replace("<br />","ZZbrZZ")}}, Result
      $bodyAllSessTp = $arrAllSessTp | ConvertTo-HTML -Fragment
      If ($arrAllSessTp.Result -match "Failed") {
        $allSessTpHead = $subHead01err
      } ElseIf ($arrAllSessTp.Result -match "Warning" -or $arrAllSessTp.State -match "WaitingTape") {
        $allSessTpHead = $subHead01war
      } ElseIf ($arrAllSessTp.Result -match "Success") {
        $allSessTpHead = $subHead01suc
      } Else {
        $allSessTpHead = $subHead01
      }      
      $bodyAllSessTp = $allSessTpHead + "Tape Backup Sessions" + $subHead02 + $bodyAllSessTp
If I read this correctly, I should be able to get the information I want, by

Code: Select all

PS C:\Windows\system32> $tapeSessions | sort creationTime | select @{Name="Job Name"; Expression = {$_.Name}}, @{Name="Total "; Expression = {$_.Info.Progress.ProcessedSize}}, @{Name="Transferred "; Expression = {$_.Info.Progress.TransferedSize}}
But, the result is:

Code: Select all

Job Name            Total  Transferred
--------            ------ ------------
Full backup to tape
Full backup to tape

When I look at a single session, it doesn't have a Info property. Could this be because no data was transferred? Also, there is a spelling error in the word 'Transfered', but that seems to be on purpose, since the property in VEEAM has a spelling error as well.
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Find size of data written to tape by tape job

Post by oleg.feoktistov »

Hi @btm,

By any chance, do you use Get-VBRSession to parse tape job sessions? The object returned in that case doesn't have Info property indeed.
The result you get means exactly that - the property you are trying to get doesn't exist. If it was really no data transferred, there would be zeroes in the corresponding fields.
Try getting tape sessions with the script below. exactly as in Shawn's script:

Code: Select all

$job = Get-VBRTapeJob
$tapeSessions = [veeam.backup.core.cbackupsession]::GetByJob($job[0].id)
$tapeSessions | sort creationTime | select @{Name="Job Name"; Expression = {$_.Name}}, `
@{Name="Total "; Expression = {$_.Info.Progress.ProcessedSize}}, `
@{Name="Transferred "; Expression = {$_.Info.Progress.TransferedSize}} 
Thanks,
Oleg
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Find size of data written to tape by tape job

Post by oleg.feoktistov »

Also, there is a spelling error in the word 'Transfered', but that seems to be on purpose, since the property in VEEAM has a spelling error as well.
Yep, sometimes it happens. But we would ruin thousands of existing scripts by fixing it, wouldn't we? :wink:
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests