PowerShell script exchange
Post Reply
tka
Service Provider
Posts: 6
Liked: 2 times
Joined: Apr 04, 2014 6:24 am
Full Name: Tim
Location: Cologne, Germany
Contact:

Start Job via Powershell with RetryBackup parameter error

Post by tka »

Hi all,

we're using powershell scripting to start our backup jobs which workes fine so far.

Since from time to time single VMs fail to backup successfully I would like to add the -RetryBackup parameter but after doing so I get the following error:

Code: Select all

+$jobresult = start-vbrjob <<<<  -Job $job -RetryBackup + CategoryInfo          : NotSpecified: (:) [Start-VBRJob], TargetInvocationException
    + FullyQualifiedErrorId : System.Reflection.TargetInvocationException,Veeam.Backup.PowerShell.Command.StartVBRJob
working script:

Code: Select all

$jobs = get-vbrjob
foreach ($job in $jobs){
    if ($job.Name -eq $jobname){
		$jobresult = start-vbrjob -Job $job
...
not working:

Code: Select all

$jobs = get-vbrjob
foreach ($job in $jobs){
    if ($job.Name -eq $jobname){
		$jobresult = start-vbrjob -Job $job -RetryBackup
...
Any ideas?

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

Re: Start Job via Powershell with RetryBackup parameter erro

Post by veremin »

May be the exception was thrown, because backup console had tried to run retry cycle on non-failed job? Can you try to assign to a variable just one job that has failed the last time and try to retry it with the following code:

Code: Select all

Start-VBRJob -Job $FailedJob -RetryBackup
If that works, you can then add some checking portion to the code that will distinguish failed jobs from non-failed ones and start retry cycle in accordance.

Thanks.
tka
Service Provider
Posts: 6
Liked: 2 times
Joined: Apr 04, 2014 6:24 am
Full Name: Tim
Location: Cologne, Germany
Contact:

Re: Start Job via Powershell with RetryBackup parameter erro

Post by tka »

Looks like that was exaclty the case. I misinterpreted the parameter... Thanks!

t.
veremin
Product Manager
Posts: 20271
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start Job via Powershell with RetryBackup parameter erro

Post by veremin »

Got it. So, some additional checks are needed. For instance,

Code: Select all

foreach ($Job in Get-VBRJob)
{
if ($Job.GetLastResult() -eq "Failed")
{
Start-VBRJob -Job $Job -RetryBackup
}
else{...}
}
Thanks.
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 19 guests