PowerShell script exchange
Post Reply
arun.kr
Service Provider
Posts: 25
Liked: never
Joined: Aug 16, 2014 1:13 am
Full Name: Arun Kumar
Contact:

New VEEAM backup job script

Post by arun.kr »

Hello ,

I have to create some veeam backup jobs and I am using below script:

Code: Select all

$csv = import-csv "C:\temp\AssessMed.csv"
$entity = Get-VBRServer -Name "vcenter.local"
$repo = Get-VBRBackupRepository -ScaleOut

foreach ($line in $csv) {

Add-VBRViBackupJob -Name $line.name -Description $line.Description -BackupRepository $repo -Entity ($Entity | Find-VBRViEntity -name $csv.Entity)

}
My csv file looks like

JobName,Entity,Description
ASMD_PROD_VM1,VM1,'Domain Controller'
ASMD_PROD_VM1,VM2,'Terminal Server 4'

everything works fine except the script adds all VMs in both jobs. While I want job1 will have only object that is VM1 and job2 will have VM2 to process.

Thanks
Arun
veremin
Product Manager
Posts: 20414
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: New VEEAM backup job script

Post by veremin » 1 person likes this post

While adding VMs to backup jobs, you're using $csv variable instead of $line; this must be the reason.

Code: Select all

Add-VBRViBackupJob -Name $line.name -Description $line.Description -BackupRepository $repo -Entity ($Entity | Find-VBRViEntity -name $csv.Entity)
Try the following example:

Code: Select all

Add-VBRViBackupJob -Name $line.name -Description $line.Description -BackupRepository $repo -Entity ($Entity | Find-VBRViEntity -name $line.Entity)
Thanks.
arun.kr
Service Provider
Posts: 25
Liked: never
Joined: Aug 16, 2014 1:13 am
Full Name: Arun Kumar
Contact:

Re: New VEEAM backup job script

Post by arun.kr »

Thanks. it is working.
veremin
Product Manager
Posts: 20414
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: New VEEAM backup job script

Post by veremin »

You're welcome. Should other help with scripting be needed, don't hesitate to let us know. Thanks.
adrian138
Influencer
Posts: 24
Liked: never
Joined: Aug 08, 2018 7:41 am
Full Name: adrian reinhard
Contact:

Re: New VEEAM backup job script

Post by adrian138 »

Hi, is there a script sample i can use to backup vms from VMWARE and also exclude Partitions?

thanks alot, adrian
veremin
Product Manager
Posts: 20414
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: New VEEAM backup job script

Post by veremin »

Can you elaborate on your request? You want to backup specific VMs, but make backup jobs exclude several virtual disks from processing? Thanks!
karim
Enthusiast
Posts: 51
Liked: 5 times
Joined: Oct 17, 2018 9:01 am
Contact:

Re: New VEEAM backup job script

Post by karim »

adrian138 wrote: Nov 14, 2018 3:00 pm Hi, is there a script sample i can use to backup vms from VMWARE and also exclude Partitions?

thanks alot, adrian
hello
adding the vm named VM to the job named JOB with disk scsi 0:2 exclusion :

Code: Select all

$crmjob = Get-VBRJob -Name "JOB"
Find-VBRViEntity -Name "VM1" | Add-VBRViJobObject -Job $crmjob
$object = Get-VBRJob -Name "JOB" | Get-VBRJobObject -Name "VM1"
$objInfo = $object.Info
$objInfo.DiskFilter = "Ver8|2002"
[Veeam.Backup.Core.CObjectInJob]::Update($objInfo)
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests