Add-VBRBackupJob....what can it do??

PowerShell script exchange

Add-VBRBackupJob....what can it do??

Veeam Logoby maverick964_uk » Mon Jun 03, 2013 2:32 pm

ok, I need to create 20 backup jobs all the same but different names. ie. backup-day-1 to day-20

In the backup I want to specify the following:
1. Specify a particular datastore
2. specify a certain proxy
3. Full backup 7 days a week
4. synthetic full off
5. compression off
6. post activity job "c:\script.bat <arg1> <arg2> <arg3>"

Can all this be done via powershell and add-vbrbackupjob / set-vbrjoboptions ???

I cant copy jobs as I dont have the enterprise version....

So, can powershell help me as I have alot of backup jobs to create....

thanks
maverick964_uk
Expert
 
Posts: 102
Liked: 3 times
Joined: Thu May 09, 2013 8:57 am
Full Name: Mike Lavery

Re: Add-VBRBackupJob....what can it do??

Veeam Logoby maverick964_uk » Tue Jun 04, 2013 3:01 pm

is this possible??
maverick964_uk
Expert
 
Posts: 102
Liked: 3 times
Joined: Thu May 09, 2013 8:57 am
Full Name: Mike Lavery

Re: Add-VBRBackupJob....what can it do??

Veeam Logoby foggy » Tue Jun 04, 2013 4:13 pm

Mike, our main PowerShell guru (Vladimir) is currently on vacation, please be patient, I'm sure he will be able to assist you when he is back next week. Thanks.
foggy
Veeam Software
 
Posts: 14716
Liked: 1075 times
Joined: Mon Jul 11, 2011 10:22 am
Full Name: Alexander Fogelson

Re: Add-VBRBackupJob....what can it do??

Veeam Logoby tsightler » Tue Jun 04, 2013 9:19 pm

Yes, all of this can be done and there are already examples of similar scripts right here on the forum in the Getting Started section. See specifically Code Examples and "How to start" *beta* - Creating/Editing Jobs.
tsightler
Veeam Software
 
Posts: 4767
Liked: 1737 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Re: Add-VBRBackupJob....what can it do??

Veeam Logoby maverick964_uk » Thu Jun 06, 2013 1:28 pm

many thanks. I look forward to Vladimir's reply....

I will look at your link Tom, thanks!
maverick964_uk
Expert
 
Posts: 102
Liked: 3 times
Joined: Thu May 09, 2013 8:57 am
Full Name: Mike Lavery

Re: Add-VBRBackupJob....what can it do??

Veeam Logoby v.Eremin » Tue Jun 11, 2013 11:29 am 1 person likes this post

Hi, Mike.

1. Please be aware that backup repository can be only specified during the job creation. Once specified it can’t be later changed via Powershell.

How to get a repository:

Code: Select all
Get-VBRBackupRepository -name "Name of your Repository"

How to set a given repository during job creation:

Code: Select all
$MyRepository = Get-VBRBackupRepository -name "Name of your Repository"
Add-VBRViBackupJob -Name $JobName -BackupRepository $MyRepository -Entity $ObjectsToBackup


2. How to disable proxy auto detection and specify the required one:

Code: Select all
asnp VeeamPSSnapin

#First part of the script is responsible for disabling SourceProxyAutoDetection

$Job = Get-VBRJob | ?{$_.Name –eq “Name of your Job”}
$vo= $job.GetOptions()
$vo.JobOptions.SourceProxyAutoDetect = $False
$job.SetOptions($vo)

#After having done that, our goal is to exclude from our job all proxies except for one.
#Thus, second part of the script is checking proxies which names don't coincide with the name of the proxy we're going to leave.
#The result of that process is being saved in $Proxies list.
#In the end, within the cycle, we delete all of such proxies, meanwhile create the only one ($ProxytoAdd).
#Little note: $ProxyType = 0 means SourceProxy, 1 - TargetProxy.

$ProxyType = 0
$ProxyToAdd = Get-VBRViProxy| ?{$_.Name –eq "Name of proxy you're going to leave"}
$Proxies= Get-VbrViProxy | ?{$_.Name –ne $ProxyToAdd}

foreach($ProxytoDelete in $Proxies)
{
foreach($ProxyInfo in ([Veeam.Backup.DBManager.CDBManager]::Instance.JobProxies.GetJobProxies($Job.id, $ProxyType)))
{
if($ProxyInfo.ProxyId -eq $ProxyToDelete.id)
{
[Veeam.Backup.DBManager.CDBManager]::Instance.JobProxies.Delete($ProxyInfo.id)
}
}
}
[Veeam.Backup.Core.CJobProxy]::Create($Job.id, $ProxyToAdd.id, $ProxyType)


3. How to set full backup 7 days a week:

Code: Select all
$Job = Get-VBRJob -name "Name of your backup Job"
$Options = $Job.GetOptions()
$Options.BackupStorageOptions.EnableFullBackup = $True
$Options.BackupTargetOptions.FullBackupDays = "Monday", "Tuesday" , "Wednesday" , "Thursday" , "Friday" , "Saturday" , "Sunday"
$Job.SetOptions($Options)


4. How to disable synthetic full backup:

Code: Select all
asnp VeeamPSSnapin
$Job = Get-VBRJob -name "Name of your backup Job"
$Options = $Job.GetOptions()
$Options.BackupTargetOptions.TransformFullToSyntethic = $False
$Job.SetOptions($Options)


5. How to disable compression:

Code: Select all
asnp VeeamPSSnapin
$Job = Get-VBRJob -name "Name of your backup Job"
$Options = $Job.GetOptions()
$Options.BackupStorageOptions.CompressionLevel = "0"
$Job.SetOptions($Options)


6. How to set post job activity:

Code: Select all
asnp VeeamPSSnapin
$Job = Get-VBRJob | ?{$_.Name –eq “Name of your Job”}
$jo = $job.GetOptions()
$jo.PostJobCommand.Enabled = $True
$jo.PostJobCommand.Commandline = "c:\script.bat"
$job.SetOptions($jo)


Hope this helps.
Thanks.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Add-VBRBackupJob....what can it do??

Veeam Logoby maverick964_uk » Thu Jun 13, 2013 11:39 am

thanks for all the great information Vladimir
maverick964_uk
Expert
 
Posts: 102
Liked: 3 times
Joined: Thu May 09, 2013 8:57 am
Full Name: Mike Lavery

Re: Add-VBRBackupJob....what can it do??

Veeam Logoby v.Eremin » Thu Jun 13, 2013 11:43 am 1 person likes this post

You’re welcome. Feel free to contact me, should any other questions regarding our product arise. Thanks.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

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