PowerShell script exchange
Post Reply
jfrmilner
Novice
Posts: 9
Liked: 1 time
Joined: May 23, 2012 9:55 am
Full Name: John Milner
Contact:

Individual VM backup duration

Post by jfrmilner » 1 person likes this post

Hi all,

Using the GUI in B&R 6.1 you can right-click a job and select report, this provides me with a "Veeam Backup Session Report *.html". One of the things I like about this report is that it displays stats at the individual VM level as well as the whole job. I can see that I can get information regarding the whole job with the Get-VBRBackupSession cmdlet but I'm struggling to locate this information at the individual VM level, can anyone point me in the right location?
Regards,

jfrmilner
http://en.gravatar.com/jfrmilner
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Individual VM backup duration

Post by Sethbartlett » 1 person likes this post

Code: Select all

$Sessions = Get-VBRBackupSession -name "Name of Session"
$Sessions[0].Logger.GetLog().UpdatedRecords
The above code would look at the first session in a list of sessions and give you the XML data that you are seeing in the realtime statistics.
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
jfrmilner
Novice
Posts: 9
Liked: 1 time
Joined: May 23, 2012 9:55 am
Full Name: John Milner
Contact:

Re: Individual VM backup duration

Post by jfrmilner »

Sethbartlett,

Excellent thank you. How about Read, Transferred, Duration do you know where I could find this?
Regards,

jfrmilner
http://en.gravatar.com/jfrmilner
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Individual VM backup duration

Post by Sethbartlett »

Is this data available in the GUI for each VM? I typically only see this on the entire job.
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
jfrmilner
Novice
Posts: 9
Liked: 1 time
Joined: May 23, 2012 9:55 am
Full Name: John Milner
Contact:

Re: Individual VM backup duration

Post by jfrmilner »

Sethbartlett,

Well it is available in the report which seems to be generated via the GUI, for example:

Image
photo hosting sites

Any help in extracting this information with PowerShell would be extremely helpful.
Regards,

jfrmilner
http://en.gravatar.com/jfrmilner
jfrmilner
Novice
Posts: 9
Liked: 1 time
Joined: May 23, 2012 9:55 am
Full Name: John Milner
Contact:

Re: Individual VM backup duration

Post by jfrmilner »

Anyone else? Maybe I could extract this from SQL?
Regards,

jfrmilner
http://en.gravatar.com/jfrmilner
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Individual VM backup duration

Post by Vitaliy S. » 2 people like this post

Try this PS cmdlet to get the information you need:

Code: Select all

$session = Get-VBRBackupSession | use filters here
$task = GetVBRTaskSession $session | use filters here
$task.Progress – contains information about data size etc. 
jfrmilner
Novice
Posts: 9
Liked: 1 time
Joined: May 23, 2012 9:55 am
Full Name: John Milner
Contact:

Re: Individual VM backup duration

Post by jfrmilner »

Exactly what I was looking for many thanks.
Regards,

jfrmilner
http://en.gravatar.com/jfrmilner
masonit
Service Provider
Posts: 327
Liked: 23 times
Joined: Oct 09, 2012 2:30 pm
Full Name: Maso
Contact:

Re: Individual VM backup duration

Post by masonit » 1 person likes this post

Vitaliy S. wrote:Try this PS cmdlet to get the information you need:

Code: Select all

$session = Get-VBRBackupSession | use filters here
$task = GetVBRTaskSession $session | use filters here
$task.Progress – contains information about data size etc. 
Hi

Should this one still work in Veeam 8? I get this:

Code: Select all

add-pssnapin "VeeamPSSnapIn"
$session = Get-VBRBackupSession
$task = Get-VBRTasksession $session
$task.Progress
Get-VBRTaskSession : Cannot convert 'System.Object[]' to the type 'Veeam.Backup.Core.CBackupSession' required by parameter 'Session'. Specified method is not 
supported.
At line:3 char:28
+ $task = Get-VBRTasksession $session
+                            ~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-VBRTaskSession], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Veeam.Backup.PowerShell.Command.GetVBRTaskSession
\Masonit
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Individual VM backup duration

Post by veremin »

Get-VBRTaskSession expects a single entity, not an array. Thus, the issues. Thanks.
masonit
Service Provider
Posts: 327
Liked: 23 times
Joined: Oct 09, 2012 2:30 pm
Full Name: Maso
Contact:

Re: Individual VM backup duration

Post by masonit » 1 person likes this post

Hi again

I have now created a script that shows the data i want. But the problem is that I would like to sort the entire result after ReadSize. But I can't get it to work and I guess the main problem is that the result is shown in multiple arrays based on Jobname?

Code: Select all

$BackupSessions = ""
add-pssnapin "VeeamPSSnapIn"
$Jobs = Get-VBRJob
foreach ($job in $Jobs) {
   $BackupSessions = Get-VBRBackupSession | where {$_.JobName -eq $job.Name} | Sort creationtime -Descending | select -First 1 
   Get-VBRTaskSession $BackupSessions | Select-Object Name ,JobName ,Status,@{Name="StartTime"; Expression = {$_.Progress.StartTime}},@{Name="StopTime"; Expression = {$_.Progress.StopTime}},@{Name="ReadSize in GB"; Expression = {[math]::Round(($_.Progress.ReadSize/1024/1024/1024),1)}},@{Name="TransferedSize in GB"; Expression = {[math]::Round(($_.Progress.TransferedSize/1024/1024/1024),1)}} | Format-Table -auto
   }
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Individual VM backup duration

Post by veremin »

What do you mean by "sort the entire Result after ReadSize"? Should some values be shown in desired order or something?
tsightler
VP, Product Management
Posts: 6035
Liked: 2860 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: Individual VM backup duration

Post by tsightler » 2 people like this post

Hi Magnus. I'm not sure I followed you 100%, but here's a modification that loads the entire results from every Job/VM into a single array and thus allows the final output to be sorted by any column (example below sorts in descending order of read size). Also, it should run significantly faster by using $Job.FindLastSession() instead of running Get-VBRBackupSession mulitple times and filtering/sorting the entire list of sessions, which can be quite long. In my lab I have over 10,000 sessions and the original script took 30 seconds while the one below takes <1 second and seems to produce identical output.

Code: Select all

asnp "VeeamPSSnapIn"
$Output = @()
$Jobs = Get-VBRJob
ForEach ($Job in $Jobs) {
   $Output += Get-VBRTaskSession $Job.FindLastSession() | Select-Object Name ,JobName ,Status,@{Name="StartTime"; Expression = {$_.Progress.StartTime}},@{Name="StopTime"; Expression = {$_.Progress.StopTime}},@{Name="ReadSize in GB"; Expression = {[math]::Round(($_.Progress.ReadSize/1024/1024/1024),1)}},@{Name="TransferedSize in GB"; Expression = {[math]::Round(($_.Progress.TransferedSize/1024/1024/1024),1)}}
   }
$Output | Sort -Property "Readsize in GB" -Descending | Format-Table -AutoSize
masonit
Service Provider
Posts: 327
Liked: 23 times
Joined: Oct 09, 2012 2:30 pm
Full Name: Maso
Contact:

Re: Individual VM backup duration

Post by masonit »

You followed me 100%.. Looks great, thanks! :)

\Masonit
marius roma
Veteran
Posts: 459
Liked: 5 times
Joined: Feb 01, 2012 12:04 pm
Full Name: Mario
Contact:

Re: Individual VM backup duration

Post by marius roma »

It looks great!
Let me ask for 2 possible enhancements:
Is it possible to extend the search to the latest let's say 10 executions ot each job?
Is it possible to limit the analysis to replica jobs?
Regards
marius
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Individual VM backup duration

Post by veremin »

Is it possible to extend the search to the latest let's say 10 executions ot each job?
Then you should switch back to usage of Get-VBRBackupSession commandlet, since .FindLastSession() finds only the latest job session.
Is it possible to limit the analysis to replica jobs?
Just add filter portion:

Code: Select all

$Jobs = Get-VBRJob | where {$_.JobType -eq "Replica"}
Thanks.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 12 guests