PowerShell script exchange
Post Reply
rogersillars

Veeam Backup v4 wait command

Post by rogersillars »

Hi,

We only want to run one job at a time. I would like to control this via a script but when I put the commands into a batch file it starts each job. Is there any way of starting a job from the command line (either batch or powershell) and getting it to wait until it is completed?

Another option is to query the job to check to see if it is running and doing a loop but I can't see the command to do this in the documentation.

At the moment I am running job after job using the post job activity. This isn't ideal as it has hard to see each step as you have to drill into each job to see what comes next.

Thanks,
Roger
Gostev
Chief Product Officer
Posts: 31709
Liked: 7215 times
Joined: Jan 01, 2006 1:01 am
Location: Baar, Switzerland
Contact:

Re: Veeam Backup v4 wait command

Post by Gostev »

Hello Roger, if you start the job from PowerShell, the script will wait until the job execution finishes before moving to the next statement.
rogersillars

Re: Veeam Backup v4 wait command

Post by rogersillars »

Thanks. Easy fix :-)
Gostev
Chief Product Officer
Posts: 31709
Liked: 7215 times
Joined: Jan 01, 2006 1:01 am
Location: Baar, Switzerland
Contact:

Re: Veeam Backup v4 wait command

Post by Gostev »

Apparently I missed your question on querying job status, you can use the following PowerShell command for this:

Code: Select all

(Get-VBRJob JobName).GetStatus()
Although you should not need this when starting jobs from PowerShell, as I mentioned above...
rogersillars

Re: Veeam Backup v4 wait command

Post by rogersillars »

Great, thanks. What is the retry job command in powershell?
Vitaliy S.
VP, Product Management
Posts: 27325
Liked: 2778 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Veeam Backup v4 wait command

Post by Vitaliy S. »

Hello Roger,

You can use Set-VBRJobSchedule, that will allow you to edit settings for your scheduled jobs, as well as the settings that are responsible for a retry operation. For more info on the syntax of that commad, please have a look at our User Guide. Hope it helps.

Thank you.
rogersillars

Re: Veeam Backup v4 wait command

Post by rogersillars »

Thanks but does that work when you run the job from Start-VBRJob? What I want to do is run the jobs via a script, then check to see if it was suscessful. If it failed then delay and run a retry operation. If you shedule the jobs then you have this option but I can't see a way via a script.

Thanks,
Roger
Vitaliy S.
VP, Product Management
Posts: 27325
Liked: 2778 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Veeam Backup v4 wait command

Post by Vitaliy S. »

Roger,

If you start the job manually with Start-VBRJob, you can use this for a retry operation:

Code: Select all

 Start-VBRJob JobName -RetryBackup 
Also to get the status of the job please use the following command:

Code: Select all

 (Get-VBRJob JobName).GetStatus() 
Hope it helps
Burnwell
Influencer
Posts: 10
Liked: never
Joined: Nov 07, 2009 5:30 pm
Full Name: J J
Contact:

Re: Veeam Backup v4 wait command

Post by Burnwell »

Hi
I have installed Powershell 1.0 (Win 2k3), but cannot make any of the cmdlets work in the powershell console.
Do I have to connect to the Veeam Backup database somehow first, or how does this work?
Any hints on how to get started using Veeam Backup PS scripts / samples will be much appreciated?
Gostev
Chief Product Officer
Posts: 31709
Liked: 7215 times
Joined: Jan 01, 2006 1:01 am
Location: Baar, Switzerland
Contact:

Re: Veeam Backup v4 wait command

Post by Gostev »

Click Tools > PowerShell in Veeam Backup console to start PowerShell with Veeam Backup extensions available. I know very little about PowerShell, but I think if you just start PowerShell from Windows Start menu, you will need to first load Veeam Backup namespace before you can use our commands. I can find out more details from our PowerShell dev.
Burnwell
Influencer
Posts: 10
Liked: never
Joined: Nov 07, 2009 5:30 pm
Full Name: J J
Contact:

Re: Veeam Backup v4 wait command

Post by Burnwell »

Thanks Gostev. I hadn't noticed the Tools -> PowerShell. This works from within the Veeam PS console. It would be great if you can find out more from your PowerShell developers.
I would like to write a PS1 script which is being run through windows scheduler - exactly the same thing as Roger is asking for with a "success" check and a delayed retry if not successfull. The big questions is, how do i load up PowerShell from Windows Scheduler with Veeam Backup extensions available.....
fredbloggs
Service Provider
Posts: 47
Liked: never
Joined: Mar 18, 2009 1:05 am
Contact:

Re: Veeam Backup v4 wait command

Post by fredbloggs »

Just posting so I can watch this as am interested in this as well.

Would be nice if you guys could present a sample .ps1 script that could do the request above for a few jobs and can either be run interactively or through task schedular.

Just want it so I can get all my jobs to run in the quickest time without complicated scheduling, especially as CBT now allows exterrmely fast backups.
Gostev
Chief Product Officer
Posts: 31709
Liked: 7215 times
Joined: Jan 01, 2006 1:01 am
Location: Baar, Switzerland
Contact:

Re: Veeam Backup v4 wait command

Post by Gostev »

Gostev wrote:Click Tools > PowerShell in Veeam Backup console to start PowerShell with Veeam Backup extensions available. I know very little about PowerShell, but I think if you just start PowerShell from Windows Start menu, you will need to first load Veeam Backup namespace before you can use our commands. I can find out more details from our PowerShell dev.
So, here is how you register Veeam snap-in in the script:

Code: Select all

Add-PSSnapin VeeamPSSnapIn
This is how you can see all installed PowerShell snap-ins:

Code: Select all

Get-PSSnapin
Gostev
Chief Product Officer
Posts: 31709
Liked: 7215 times
Joined: Jan 01, 2006 1:01 am
Location: Baar, Switzerland
Contact:

Re: Veeam Backup v4 wait command

Post by Gostev »

fredbloggs wrote:Would be nice if you guys could present a sample .ps1 script that could do the request above for a few jobs and can either be run interactively or through task schedular.
You just start the jobs sequentially like this:

Code: Select all

Start-VBRJob Job1
Start-VBRJob Job2 
Start-VBRJob Job3 
Start-VBRJob Job4
Start-VBRJob Job5
...
Start-VBRJob JobN
As I stated above, next job in list will not be started until previously started job in list completes execution.
rogersillars

Re: Veeam Backup v4 wait command

Post by rogersillars »

Thanks everyone for your replies.

I'm after a script where I can call each job, it runs the job, at the end it checks the status of that job, if it fails it retries X times and waits X minutes before retrying. If it was successful then it goes to the next job.

I have no experience in Powershell scripts but if I get time I’ll write one and post it but if anyone else feels like doing this then please feel free.

Thanks,
Roger
Burnwell
Influencer
Posts: 10
Liked: never
Joined: Nov 07, 2009 5:30 pm
Full Name: J J
Contact:

Re: Veeam Backup v4 wait command

Post by Burnwell »

Thanks Gostev for the information.
With your help we help we now have some basic PS scripts that runs the backups one at a time. Works perfect.
Would still be nice to do a check at the end and retry failed jobs, but I too have no Powershell experience, and no idea how to script such a thing...

Regards
JJ
CTCarp
Enthusiast
Posts: 29
Liked: 2 times
Joined: Oct 13, 2011 11:46 am
Contact:

Re: Veeam Backup v4 wait command

Post by CTCarp »

I have B&R standard v5.2 - Im not sure if I understand but do I put the code "Start-VBRJob Job1" ("job1" being the name of the job) in the post script line? and for the next backup put "Start-VBRJob Job2" and so on down the list? I have 13 servers that I want to fire off sequentially
Vitaliy S.
VP, Product Management
Posts: 27325
Liked: 2778 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Veeam Backup v4 wait command

Post by Vitaliy S. »

Not really, powershell cmdlets will not be recognized by post backup job script line. You need to wrap it into a batch file first, then trigger this file from the job.

If you want to daisy chain backup jobs then look through this topic for more details.
CTCarp
Enthusiast
Posts: 29
Liked: 2 times
Joined: Oct 13, 2011 11:46 am
Contact:

Re: Veeam Backup v4 wait command

Post by CTCarp »

So I would create a batch file for each individual backup then run the batch in post script ? Sorry I dont know PS at all and I am trying to figure this out.
Vitaliy S.
VP, Product Management
Posts: 27325
Liked: 2778 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Veeam Backup v4 wait command

Post by Vitaliy S. »

Not exactly. If a first job fails, then your post backup job script will never be triggered, meaning that your PowerShell script will not be triggered either. What I am suggesting is to use a PowerShell script to start your jobs. See example below.

Long version:

Code: Select all

$job = Get-VBRJob | where {$_.Name –eq “JobName1”}
Start-VBRJob –Job ($job)
Short version:

Code: Select all

Get-VBRJob | where {$_.Name –eq “JobName1”} | Start-VBRJob
Also you would need to verify previous job result in your script using the following PowerShell command, and then implement the desired script behavior based on the returned status, in your case it should be start of a subsequent backup job.

Code: Select all

(Get-VBRJob JobName).GetStatus()
Hope this helps!
CTCarp
Enthusiast
Posts: 29
Liked: 2 times
Joined: Oct 13, 2011 11:46 am
Contact:

Re: Veeam Backup v4 wait command

Post by CTCarp »

its a start thank you. I dont know PS that well, so excuse my ill formed questions, but do I create the script in a batch then run it via task scheduler? I mean how is this done besides manually running the scripts.
Vitaliy S.
VP, Product Management
Posts: 27325
Liked: 2778 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Veeam Backup v4 wait command

Post by Vitaliy S. »

Yes, you can do it either with Task Scheduler or start it manually.
Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests