PowerShell script exchange
Post Reply
fomas
Lurker
Posts: 1
Liked: never
Joined: Aug 29, 2013 10:20 am
Contact:

Powershell Get size of the last Veeam tape job

Post by fomas »

hi all,

We are using Powershell to create our Veeam report and email it.
This all worked fine untill i was requested to implement this for the tape jobs as well.

the code I use to get my tape jobs is the following:

Code: Select all

#tape job
$Job = Get-VBRTapeJob
$AllBackupSessions  += [Veeam.Backup.Core.CBackupSession]::GetByJob($Job.Id) | select Name,Result,State,EndTime,CreationTime,AuxData | where {$_.Creationtime -like $today}

#backup job
$AllBackupSessions += Get-VBRBackupSession | select Name,Result,State,EndTime,CreationTime,AuxData | sort-object Name | where {$_.Creationtime -like $yesterday -Or $_.Creationtime -like $today}
the key issue lies within the 'auxdata':
- Tape job:

Code: Select all

Name         : Daily Hyper-V Tape Offload
Result       : Success
State        : Stopped
EndTime      : 6/04/2016 2:05:56
CreationTime : 6/04/2016 2:00:12
AuxData      : <TapeAuxData><TapeLibrary Name="HP 1x8 G2 AUTOLDR 4.30" /><TapeMediums><TapeMedium Barcode="RES006L5" Name="RES006L5" /></TapeMedium
               s><CBackupSessionWorkDetails><WorkDuration>3434720704</WorkDuration></CBackupSessionWorkDetails><SessionStarterInfo Version="1" User
               Name="s_veeam" UserDomainName="RETAIL" RunManually="False" /></TapeAuxData>
-Backup job:

Code: Select all

Name         : Daily Hyper-V Backup (Incremental)
Result       : Warning
State        : Stopped
EndTime      : 6/04/2016 1:29:40
CreationTime : 5/04/2016 22:00:00
AuxData      : <AuxData><CBackupStats><BackupSize>7493309440</BackupSize><DataSize>18323183216</DataSize><DedupRatio>87</DedupRatio><CompressRatio>
               46</CompressRatio></CBackupStats><CBackupSessionWorkDetails><WorkDuration>125797112149</WorkDuration></CBackupSessionWorkDetails><Se
               ssionStarterInfo Version="1" UserName="s_veeam" UserDomainName="RETAIL" RunManually="False" /></AuxData>
As you can see no 'DataSize' element is NOT included for tape jobs. Searching in the SQL DB I've found where the size is located in the session table. But then I would have to cross reference it to the session ID and job name. And also re-write partly or whole of my script
And since I"m working in Powershell now I would like to keep it this way.

For complete reference, here is the complete result for a tape job object:

Code: Select all

BottleneckManager         : CJobBottleneckManager
Info                      : Veeam.Backup.Model.CBackupSessionInfo
Progress                  : Veeam.Backup.Model.CBackupProgressData
StartupMode               : Normal
JobSourceType             : NET
CurrentPointId            : 00000000-0000-0000-0000-000000000000
OriginalSessionId         : 14e9340f-7bf5-46c8-80a1-1a29c408a284
IsFullMode                : True
IsRetryMode               : False
IsQuickBackup             : False
IsVeeamZip                : False
IsPlannedFailover         : False
IsReplicaFromBackup       : False
IsAdHocBackup             : False
PostActivity              : AskService
Name                      : Daily Hyper-V Tape Offload
OrigJobName               : Daily Hyper-V Tape Offload
BackupStats               : Veeam.Backup.Model.CBackupStats
WorkDetails               : Veeam.Backup.Core.CBackupSessionWorkDetails
WillBeRetried             : False
IsManuallyStopped         : False
IsTransformLaunched       : False
SessionCryptoSpec         : Veeam.Backup.Crypto.CCryptoSymmetricSpec
UserCryptoSpec            : 
SelectiveProcessingSpec   : 
StorageVerificationResult : Veeam.Backup.Core.CStorageVerificationResultContainer
IsEncryptionEnabled       : False
SessionInfo               : Veeam.Backup.Model.CBackupSessionInfo
Id                        : 14e9340f-7bf5-46c8-80a1-1a29c408a284
JobType                   : VmTapeBackup
JobName                   : Daily Hyper-V Tape Offload
JobSpec                   : 
JobTypeString             : Other job type
Operation                 : 
Description               : 
BaseProgress              : 100
IsCompleted               : True
IsWorking                 : False
IsStarting                : False
IsPostprocessing          : False
JobId                     : 2dfa4ec0-afab-4a9f-90ec-cbb9ff3fb654
Result                    : Success
State                     : Stopped
EndTime                   : 6/04/2016 2:05:56
CreationTime              : 6/04/2016 2:00:12
AuxData                   : <TapeAuxData><TapeLibrary Name="HP 1x8 G2 AUTOLDR 4.30" /><TapeMediums><TapeMedium Barcode="RES006L5" Name="RES006L5" /
                            ></TapeMediums><CBackupSessionWorkDetails><WorkDuration>3434720704</WorkDuration></CBackupSessionWorkDetails><SessionSt
                            arterInfo Version="1" UserName="s_veeam" UserDomainName="RETAIL" RunManually="False" /></TapeAuxData>
IsLowerAgentPriority      : False
LogName                   : Job.Daily_Hyper-V_Tape_Offload
LogsSubFolder             : Daily_Hyper-V_Tape_Offload
Logger                    : Veeam.Backup.Core.XmlLogger
Tracer                    : Veeam.Backup.Core.CSessionLogTracer
Was anyone able allready to get the job size / data size from a tape job in Veeam via Powershell?

Thanks in advance,
Thomas
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Powershell Get size of the last Veeam tape job

Post by veremin »

Are you using backup or file to tape job? In the former case, have you thought about using the very same approach? Something like the following:

Code: Select all

$TapeBackup = Get-VBRTapeBackup | where {$_.name -eq "Name of your backup"}
($TapeBackup.GetAllStorages().stats.backupsize | Measure-Object -Sum).sum/1Gb
Thanks.
gmaciolek
Novice
Posts: 4
Liked: 1 time
Joined: Apr 20, 2016 3:59 pm
Full Name: Geoff Maciolek
Contact:

Re: Powershell Get size of the last Veeam tape job

Post by gmaciolek »

So... I'm on Veeam 9 (free, no less) and am trying to get - basically - anything about tape jobs. Get-VBRTapeBackup is listed as obsolete/deprecated, and doesn't return anything.

I'm not sure what's user error here, what's a result of running on "Free," and what could be a result of the 8->9 upgrade.

I'm reaaaallly hoping to be able to programatically pull reports about my existing tape backups, but I'm not having any luck at all.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Powershell Get size of the last Veeam tape job

Post by veremin »

You can try the script that I've written previously.

Nevertheless, I'm not 100% sure whether it's going to work on free edition - the latter supports only limited number of PS cmdlets that we've made available there deliberately.

Thanks.
gmaciolek
Novice
Posts: 4
Liked: 1 time
Joined: Apr 20, 2016 3:59 pm
Full Name: Geoff Maciolek
Contact:

Re: Powershell Get size of the last Veeam tape job

Post by gmaciolek »

I ran the following (from the other thread):

Code: Select all

foreach ($TapeCatalog in Find-VBRTapeCatalog)
{ 
$Info = ($TapeCatalog | select Name), ((Get-VBRTapeMedium | where {$_.mediafamilyitem.id -eq $TapeCatalog.Versions.Parts.backupset.MediaFamilyId}) | select barcode)  
$Info | Format-Table -Property Name, Barcode
}
And I got the following (and no results). First line in orange, the rest in red. Again, I'm not sure if this is because of my upgrade, or the use of the free edition, or some other unknown cause.

Code: Select all

WARNING: This cmdlet is obsolete and no longer supported
Find-VBRTapeCatalog : Object reference not set to an instance of an object.
At line:1 char:26
+ foreach ($TapeCatalog in Find-VBRTapeCatalog)
+                          ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Find-VBRTapeCatalog], NullReferenceException
    + FullyQualifiedErrorId : System.NullReferenceException,Veeam.Backup.PowerShell.Command.FindVBRTapeCatalog
I'm curious if anyone has a free edition with a bunch of files copied to tape that they can try this on.
Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests