writing multiple veeam jobs to 1 tape job

PowerShell script exchange

writing multiple veeam jobs to 1 tape job

Veeam Logoby hagepat » Mon Oct 01, 2012 12:09 pm

Hi all,

I have a problem with a customer that has 3 different veeam jobs.
The idea is that *.vbk files of all 3 jobs are wrtiten to tape.
In what job should I fire up powershell script? How do I set up job scheduling so that backups are finished before powershell script runs?

Here's the script I have for only 1 job:

# Remoting must be enabled on the BackupExec Server
# And user must have access to complete task on Veeam and BE

if ((Get-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue) -eq $null) {
Add-PsSnapin VeeamPSSnapIn
}

$veeamJobName = "test"
$backupExecJob = "veeam2tape"
$backupExecSvr = "MGMT01"
$backupExecPath = "C:\Program Files\Symantec\Backup Exec"

if ((Get-VBRJob | ?{$_.Name -eq $veeamJobName}).GetLastResult() -eq "Success") {
$latestOib = Get-VBRBackup | ?{$_.JobName -eq $veeamJobName} | Get-VBRRestorePoint | Sort CreationTime -Descending | Select -First 1
$latestOib
$storage = $latestOib.GetStorage()
$storage.FilePath

$file = Get-Item $storage.FilePath
if ($file.Attributes -band ([System.IO.FileAttributes]::Archive)) {
Invoke-Command -ComputerName $backupExecSvr -ScriptBlock {
param (
[PSObject]$storage,
[PsObject]$file,
[String]$backupExecJob,
[String]$backupExecPath
)

& "$backupExecPath\bemcmd.exe" -o2 -j:$backupExecJob -s:$storage.FilePath -m Tapes-Weekdays -r -w
$file.Attributes = 'Archive'
} -ArgumentList $storage, $file, $backupExecJob, $backupExecPath
}
}


Hope that someone can help me with that.

Kind regards,

Patrick Hagen
hagepat
Veeam ProPartner
 
Posts: 15
Liked: never
Joined: Tue Aug 31, 2010 1:17 pm

Re: writing multiple veeam jobs to 1 tape job

Veeam Logoby Sethbartlett » Mon Oct 01, 2012 3:33 pm

You should have Job 1 kick off Job 2, Job 2 kick off Job 3 and Job 3 kick off the powershell script. You can do this with the post job script for each job.

Job 1 -> Job 2 -> Job 3 -> Powershell script.
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: writing multiple veeam jobs to 1 tape job

Veeam Logoby yizhar » Mon Oct 01, 2012 11:32 pm

Hi.

I suggest that you consider the following approach:

1. Disable the scheduling in Veeam (and use task scheduler instead).

2. Use a single powershell script to run the 3 jobs (unless you want them to run at the same time).
See the example I have just posted here:
viewtopic.php?f=26&t=13710
Send an email report for the veeam backup jobs.

3. At the end of the script, launch the backup exec script.
Send another email report after the backup exec job (you can use backup exec built in email notification).

4. Schedule the powershell script using Task Scheduler

5. Double check that it works as expected,
Also test and debug for gochas situations such as what happens if the backup exec server is unavailable, if there is no tape in the drive, and other potential problems.


Yet another approach is to schedule the veeam backup jobs at evening, and backup exec to tape during the day, assuming that veeams needs only few hours to complete all jobs.

Yizhar Hurwitz
http://yizhar.mvps.org
yizhar
Expert
 
Posts: 179
Liked: 48 times
Joined: Mon Sep 03, 2012 5:28 am
Full Name: Yizhar Hurwitz

Re: writing multiple veeam jobs to 1 tape job

Veeam Logoby yizhar » Mon Oct 01, 2012 11:40 pm

Sethbartlett wrote:You should have Job 1 kick off Job 2, Job 2 kick off Job 3 and Job 3 kick off the powershell script. You can do this with the post job script for each job.

Job 1 -> Job 2 -> Job 3 -> Powershell script.


Hi.
I'm against the above approach.
It will work, but has potential for problems, for example:

* future changes - an admin removes or modifies a job and forgets to update the chain. This method is a bit error prone.
Also Changing the jobs order is problematic and error prone (example - adding Job4 to run after Job 1 and before Job 2).

* you wish to run a single job for some reason (example - planned maintanance of specific VM or group) - you don't want to fire the whole chain in that case.

My suggestion:
Either schedule each job individualy using Veeam, Or use Task Scheduler + Script to run them all,
but try not to make one job dependant on configuration of another.

Yizhar Hurwitz
http://yizhar.mvps.org
yizhar
Expert
 
Posts: 179
Liked: 48 times
Joined: Mon Sep 03, 2012 5:28 am
Full Name: Yizhar Hurwitz

Re: writing multiple veeam jobs to 1 tape job

Veeam Logoby hagepat » Tue Oct 02, 2012 7:58 am

Hi Yizhar,

Thanks for your reply.

Do you mean here "3. At the end of the script, launch the backup exec script."
That I can paste my code after your code?
Problem is that backup to tape only happens in the weekends. So actually There should be a schedule in the powershell script that only fires up backup to tape after Friday backup. How can I realise that?
Maybe you can help me with writing a complete code thats starts 3 jobs @once daily, and friday if backup with veeam is finished it writes data to tape through backup exec.

Kind regards,
hagepat
Veeam ProPartner
 
Posts: 15
Liked: never
Joined: Tue Aug 31, 2010 1:17 pm

Re: writing multiple veeam jobs to 1 tape job

Veeam Logoby yizhar » Wed Oct 24, 2012 9:16 pm

Hi.

In that case, maybe the simple solution will be:
Option 1:
* run the veeam jobs daily Monday to Friday (using either a script to launch all jobs from task scheduler, or veeams integral schedules per job).
* use backup exec own scheduler to start backup to tape every Saturday morning (this will allow friday backup to finish).

Or - option 2:
* run the veeam jobs daily Monday to Thursday (using either a script to launch all jobs from task scheduler, or veeams integral schedules per job).
* use a wrapper script on Friday that will first launch veeam, then launch backup exec.

Yizhar
yizhar
Expert
 
Posts: 179
Liked: 48 times
Joined: Mon Sep 03, 2012 5:28 am
Full Name: Yizhar Hurwitz


Return to PowerShell



Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests