PowerShell script exchange
Post Reply
tka
Novice
Posts: 5
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 » 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.

veremin
Product Manager
Posts: 16906
Liked: 1440 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 » 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.

tka
Novice
Posts: 5
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 » Dec 18, 2014 8:06 am

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

t.

veremin
Product Manager
Posts: 16906
Liked: 1440 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 » 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.

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests