Script to start all backup jobs and then wait

PowerShell script exchange

Script to start all backup jobs and then wait

Veeam Logoby asdok » Sat Jun 23, 2012 12:13 am

Hi there,

I have a requirement to run several Veeam backup jobs and then backup to tape.

At the moment my powershell script runs each Veeam backup job one after the other and then starts a backup exec job to backup the Veeam backup files to tape.

Is it possible to script a mechanism in which all Veeam jobs could be started in parallel and then run the backup exec job only after the last Veeam job completes?
asdok
Service Provider
 
Posts: 4
Liked: never
Joined: Sun Jan 01, 2006 1:01 am

Re: Script to start all backup jobs and then wait

Veeam Logoby Damon » Tue Jul 17, 2012 1:55 am

Possible? Yes. Recommended? no.

I wouldn't run all the jobs at once unless you have a very distributed load--multiple proxies/storage locations/hosts.

It would take some coding though. You could check the SQL DB for any entries in Backup.TrackedActions.Locks or for a change in the job status (I forget which table that is in). Set that check for a loop that exits when the check fails and then run the BackupExec tape job.
Damon
Influencer
 
Posts: 16
Liked: never
Joined: Sun May 29, 2011 1:55 am

Re: Script to start all backup jobs and then wait

Veeam Logoby Sethbartlett » Tue Jul 17, 2012 5:44 pm

This should work for what you need, this will do ALL the jobs, if you need to JUST do backup jobs, let me know.
Code: Select all
Get-VBRJob | Start-VBRJob -RunAsync

$JobList = New-Object System.Collections.ArrayList
foreach($Job in (Get-VBRJob))
{
   $JobList.Add($Job)
}

while($JobList.Count -ne 0)
{
   foreach($Job in $JobList)
   {
      if($Job.IsStopped() -eq $true)
      {
         $JobList.Remove($Job)
      }
   }
}
Run your BackupExec here.
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett

Re: Script to start all backup jobs and then wait

Veeam Logoby Sethbartlett » Wed Jul 18, 2012 3:19 am

You will want to add a pause/sleep 10 or so after the if statement, I forgot that!
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett

Re: Script to start all backup jobs and then wait

Veeam Logoby Sethbartlett » Wed Jul 18, 2012 4:02 am

Okay, if I could delete my posts, I would, but my mistakes show that I'm human ;)

Here is the revised code:

Code: Select all
$Jobs = Get-VBRJob
$Jobs | Start-VBRJob -RunAsync

$JobList = New-Object System.Collections.ArrayList
foreach($Job in $Jobs)
{
   $JobList.Add($Job)
}

while($JobList.Count -ne 0)
{
   foreach($Job in $Jobs)
   {
      if($Job.IsStopped() -eq $true)
      {
         $JobList.Remove($Job)
      }
     sleep 10
   }
}
Run your BackupExec here.

Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 8 guests