PowerShell script exchange
Post Reply
maverick964_uk
Expert
Posts: 102
Liked: 3 times
Joined: May 09, 2013 8:57 am
Full Name: Mike Lavery
Contact:

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

Post by maverick964_uk »

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: May 09, 2013 8:57 am
Full Name: Mike Lavery
Contact:

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

Post by maverick964_uk »

is this possible??
foggy
Veeam Software
Posts: 21139
Liked: 2141 times
Joined: Jul 11, 2011 10:22 am
Full Name: Alexander Fogelson
Contact:

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

Post by foggy »

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.
tsightler
VP, Product Management
Posts: 6035
Liked: 2860 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

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

Post by tsightler »

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.
maverick964_uk
Expert
Posts: 102
Liked: 3 times
Joined: May 09, 2013 8:57 am
Full Name: Mike Lavery
Contact:

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

Post by maverick964_uk »

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

I will look at your link Tom, thanks!
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

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

Post by veremin » 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.
maverick964_uk
Expert
Posts: 102
Liked: 3 times
Joined: May 09, 2013 8:57 am
Full Name: Mike Lavery
Contact:

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

Post by maverick964_uk »

thanks for all the great information Vladimir
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

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

Post by veremin » 1 person likes this post

You’re welcome. Feel free to contact me, should any other questions regarding our product arise. Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests