PowerShell script exchange
Post Reply
jevao
Enthusiast
Posts: 29
Liked: 3 times
Joined: Oct 28, 2011 11:38 pm
Full Name: James Collison
Contact:

get-vbrbackupsession question

Post by jevao »

After upgrading to Veeam 8 trying to use “get-vbrbackupsession” to find instance that ran less than 24 hours ago.

Code: Select all

$job = Get-VBRJob | ?{$_.Name -eq “Linux-80”}
$session = get-vbrbackupsession -name $job.name
$session
Searching through the objects, I do not find a record for last night on 8/12/2015.

But I do find a record for last night if I run the following command and look through the objects:

Code: Select all

$session = get-vbrbackupsession
$session

BottleneckManager         : CJobBottleneckManager
Info                      : Veeam.Backup.Model.CBackupSessionInfo
OrigJobName               : Linux-80
EndTime                   : 8/12/2015 2:55:26 AM
CreationTime              : 8/12/2015 1:10:21 AM
Any ideas why “get-vbrbackupsession” would have the instance and “get-vbrbackupsession -name $job.name” would not have it?

Thanks for your help.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: get-vbrbackupsession question

Post by veremin »

I think it's happened because session might have a different name than a corresponding job. For instance, session name contains additional information regarding job cycle, such as "Job Name (Full)", "Job Name (Retry 1)", etc.

Can you try to get session name and see whether my assumption is correct?

Code: Select all

$Session.name
Thanks.
jevao
Enthusiast
Posts: 29
Liked: 3 times
Joined: Oct 28, 2011 11:38 pm
Full Name: James Collison
Contact:

Re: get-vbrbackupsession question

Post by jevao »

Ah, yes, you are right. The name of the vbrbackupsession is now different than the name of the job.

Code: Select all


PS C:\>   $session1 = get-vbrbackupsession

PS C:\> $session1.name | sls 80
Linux-80 (Reverse Incremental)
Linux-80
Linux-80 (Reverse Incremental)
Linux-80
Linux-80 (Retry 1)
Linux-80
Linux-80

PS C:\> $session1.jobname | sls 80
Linux-80
Linux-80
Linux-80
Linux-80
Linux-80
Linux-80
Linux-80

PS C:\> $session1 | ? { $_.name.Startswith("Linux-80")}    # Will include the object:
Name                      : Linux-80 (Reverse Incremental)
JobName                   : Linux-80
CreationTime              : 8/12/2015 1:10:21 AM

This works:

Code: Select all


PS C:\> ######  Wrong ######  $session = get-vbrbackupsession -name $job.name |  ?{$_.CreationTime -ge (Get-Date).addhours(-24)}
PS C:\> $session1 = get-vbrbackupsession
PS C:\> $session2 =  $session1 | where { $_.jobname -eq $job.name }
PS C:\> $session =  $session2 | where { $_.creationtime -ge (Get-Date).addhours(-24)}
PS C:\> $session
Name                      : Linux-80 (Reverse Incremental)
JobName                   : Linux-80
CreationTime              : 8/13/2015 1:10:23 AM

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

Re: get-vbrbackupsession question

Post by veremin » 1 person likes this post

You can also get the latest job session in a different way. Get a job you want, and, then, use FindLastSession() method.

Code: Select all

(Get-VBRJob -Name "Name of your Job").FindLastSession()
Thanks.
Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 14 guests