Start Job via Powershell with RetryBackup parameter error

PowerShell script exchange

Start Job via Powershell with RetryBackup parameter error

Veeam Logoby tka » Wed Dec 17, 2014 9:06 am

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.
tka
Lurker
 
Posts: 2
Liked: never
Joined: Fri Apr 04, 2014 6:24 am
Full Name: tka

Re: Start Job via Powershell with RetryBackup parameter erro

Veeam Logoby v.Eremin » Wed Dec 17, 2014 11:25 am

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.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 969 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Start Job via Powershell with RetryBackup parameter erro

Veeam Logoby tka » Thu Dec 18, 2014 8:06 am

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

t.
tka
Lurker
 
Posts: 2
Liked: never
Joined: Fri Apr 04, 2014 6:24 am
Full Name: tka

Re: Start Job via Powershell with RetryBackup parameter erro

Veeam Logoby v.Eremin » Thu Dec 18, 2014 9:30 am

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.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 969 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 8 guests