PowerShell script exchange
Post Reply
Yuya
Enthusiast
Posts: 82
Liked: 2 times
Joined: Jan 30, 2013 9:32 am
Contact:

way to run Agent Backup Job on VBR console using PowerShell

Post by Yuya »

Hello,

VBR 9.5 U3 was released, Veeam Agent was integrated.
I want to run Agent Backup Job on VBR console using PowerShell.
It could not be run with the following command.
----
Get-VBRJob -Name "Agent Backup Job 1" | Start-VBRJob
----

Do you know any way?
Dima P.
Product Manager
Posts: 14726
Liked: 1707 times
Joined: Feb 04, 2013 2:07 pm
Full Name: Dmitry Popov
Location: Prague
Contact:

Re: way to run Agent Backup Job on VBR console using PowerSh

Post by Dima P. »

Hello Yuya,

PowerShell options in this version are limited to host discovery and agent deployment tasks, but we plan to provide full PS support for agent management in next version. If there is a workaround now, I am sure v.Eremin will provide it.
tdewin
Veeam Software
Posts: 1818
Liked: 655 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: way to run Agent Backup Job on VBR console using PowerSh

Post by tdewin »

Highly unsupported and did yield an error:

Code: Select all

$agentname = "VBR"
[Veeam.Backup.Core.CBackupJob]::Find($agentname) | Start-VBRJob
bbuchan
Service Provider
Posts: 10
Liked: 5 times
Joined: May 19, 2016 3:45 pm
Full Name: Bryan Buchan
Contact:

Re: way to run Agent Backup Job on VBR console using PowerSh

Post by bbuchan »

I just want to be able to get the metadata from the job. The integrated agent jobs don't show up under Get-VBRJob. Am I gonna have to do a SQL query instead?? This is pretty critical to our monitoring processes and I would appreciate any help you have. Thanks.
tdewin
Veeam Software
Posts: 1818
Liked: 655 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: way to run Agent Backup Job on VBR console using PowerSh

Post by tdewin » 1 person likes this post

[Veeam.Backup.Core.CBackupJob]::Find($agentname) should return the job
masonit
Service Provider
Posts: 327
Liked: 23 times
Joined: Oct 09, 2012 2:30 pm
Full Name: Maso
Contact:

Re: way to run Agent Backup Job on VBR console using PowerSh

Post by masonit »

Hi

I understand you don't have ps support yet with vbr agent backup job created from protection group. But is there a way around to get all VBR Agent jobs and there job objects?

\Masonit
tdewin
Veeam Software
Posts: 1818
Liked: 655 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: way to run Agent Backup Job on VBR console using PowerSh

Post by tdewin »

Again this is not supported and probably in a next update, powershell agent management will expand

Getting the jobs

Code: Select all

$alljobs = [Veeam.Backup.Core.CBackupJob]::GetAll()
$winjobs = $alljobs | ? { $_.backupplatform -eq [Veeam.Backup.Common.CPlatform]::EndPoint }
$linjobs = $alljobs | ? { $_.backupplatform -eq [Veeam.Backup.Common.CPlatform]::LinuxPhysical }
Checking what protection groups are added to a job (assuming it is the same for linux jobs)

Code: Select all

$winjob = $winjobs[0]
PS C:\Users\Administrator> $winjob.GetDesktopOij()

Name                      Type       ApproxSize       Location
----                      ----       ----------       --------
Protection Group 1        Include    0.0 B
Find the last session and child sessions (although the child sessions seems a bit cryptic)

Code: Select all

PS C:\Users\Administrator> $lastrun = $winjob.FindLastSession()
PS C:\Users\Administrator> $lastrun

Job Name             State      Start Time             End Time               Result
--------             -----      ----------             --------               ------
Agent Backup Job 3   Stopped                                                  Success


$lastrun.GetChildSessions()
Again this is unsupported and I'm not part of R&D so I'm just discovering by tabbing + using get-member extensivelly
masonit
Service Provider
Posts: 327
Liked: 23 times
Joined: Oct 09, 2012 2:30 pm
Full Name: Maso
Contact:

Re: way to run Agent Backup Job on VBR console using PowerSh

Post by masonit » 1 person likes this post

Works fine, thanks! :)

\Masonit
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: way to run Agent Backup Job on VBR console using PowerSh

Post by veremin »

Just so you know - Update 4 will have fully functional PowerShell model for agent management functionality. Starting from Update 4 creative workarounds won't be needed any longer. Thanks.
masonit
Service Provider
Posts: 327
Liked: 23 times
Joined: Oct 09, 2012 2:30 pm
Full Name: Maso
Contact:

Re: way to run Agent Backup Job on VBR console using PowerShell

Post by masonit »

One more workaround needed.. :)

Tried starting a agent management job with start-vbrjob. But that didn't work. Is there a way around this? Tried looking for methods to use but no luck.

\Masonit
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: way to run Agent Backup Job on VBR console using PowerShell

Post by veremin »

Doesn't it work, if you get agent job, using the workaround above?

Code: Select all

$alljobs = [Veeam.Backup.Core.CBackupJob]::GetAll()
$winjobs = $alljobs | ? { $_.backupplatform -eq [Veeam.Backup.Common.CPlatform]::EndPoint }
$Job = $Winjobs | where {$_.Name -eq "Name of your Job"}
Start-VBRJob -Job $Job
Thanks!
masonit
Service Provider
Posts: 327
Liked: 23 times
Joined: Oct 09, 2012 2:30 pm
Full Name: Maso
Contact:

Re: way to run Agent Backup Job on VBR console using PowerShell

Post by masonit »

Sorry for late reply. But it does not work:

Code: Select all

Start-VBRJob : Job session with id '00000000-0000-0000-0000-000000000000' was not found
At line:1 char:1
+ Start-VBRJob -Job $Job
+ ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Start-VBRJob], Exception
    + FullyQualifiedErrorId : System.Exception,Veeam.Backup.PowerShell.Cmdlets.StartVBRJob
*Edit* - Sorry but it did work.. :) Job started eventhough start-vbrjob reported above error. Not so clean.. :)

\Masonit
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: way to run Agent Backup Job on VBR console using PowerShell

Post by veremin »

It's still a creative workaround, so some artifacts like the one above are absolutely possible.

Good to know, though, that everything is working regardless of exception reported.

Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests