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

Individual VM backup duration

Post by jfrmilner » Sep 30, 2012 12:56 pm 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
Expert
Posts: 282
Liked: 25 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Individual VM backup duration

Post by Sethbartlett » Oct 01, 2012 3:36 pm 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
Service Provider
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 » Oct 02, 2012 8:13 am

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
Expert
Posts: 282
Liked: 25 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Individual VM backup duration

Post by Sethbartlett » Oct 03, 2012 2:41 pm

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
Service Provider
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 » Oct 08, 2012 8:53 am

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
Service Provider
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 » Nov 06, 2012 9:29 am

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

jfrmilner
http://en.gravatar.com/jfrmilner

Vitaliy S.
Product Manager
Posts: 22863
Liked: 1538 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Individual VM backup duration

Post by Vitaliy S. » Nov 09, 2012 12:04 pm 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
Service Provider
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 » Nov 12, 2012 10:11 am

Exactly what I was looking for many thanks.
Regards,

jfrmilner
http://en.gravatar.com/jfrmilner

masonit
Service Provider
Posts: 215
Liked: 14 times
Joined: Oct 09, 2012 2:30 pm
Full Name: Magnus
Contact:

Re: Individual VM backup duration

Post by masonit » Sep 09, 2015 8:31 am 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: 16780
Liked: 1405 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Individual VM backup duration

Post by veremin » Sep 09, 2015 1:56 pm

Get-VBRTaskSession expects a single entity, not an array. Thus, the issues. Thanks.

masonit
Service Provider
Posts: 215
Liked: 14 times
Joined: Oct 09, 2012 2:30 pm
Full Name: Magnus
Contact:

Re: Individual VM backup duration

Post by masonit » Sep 10, 2015 7:16 am 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: 16780
Liked: 1405 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Individual VM backup duration

Post by veremin » Sep 10, 2015 7:39 pm

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: 5401
Liked: 2229 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: Individual VM backup duration

Post by tsightler » Sep 11, 2015 2:15 am 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: 215
Liked: 14 times
Joined: Oct 09, 2012 2:30 pm
Full Name: Magnus
Contact:

Re: Individual VM backup duration

Post by masonit » Sep 11, 2015 8:30 am

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

\Masonit

marius roma
Expert
Posts: 450
Liked: 5 times
Joined: Feb 01, 2012 12:04 pm
Full Name: Mario
Contact:

Re: Individual VM backup duration

Post by marius roma » Sep 11, 2015 11:30 am

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: 16780
Liked: 1405 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Individual VM backup duration

Post by veremin » Sep 14, 2015 10:50 am

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: No registered users and 7 guests