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

New VEEAM backup job script

Post by arun.kr » Feb 10, 2018 10:36 am

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: 16989
Liked: 1452 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: New VEEAM backup job script

Post by veremin » Feb 12, 2018 11:02 am 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: 15
Liked: never
Joined: Aug 16, 2014 1:13 am
Full Name: Arun Kumar
Contact:

Re: New VEEAM backup job script

Post by arun.kr » Feb 13, 2018 11:50 am

Thanks. it is working.

veremin
Product Manager
Posts: 16989
Liked: 1452 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: New VEEAM backup job script

Post by veremin » Feb 13, 2018 1:41 pm

You're welcome. Should other help with scripting be needed, don't hesitate to let us know. Thanks.

adrian138
Influencer
Posts: 15
Liked: never
Joined: Aug 08, 2018 7:41 am
Full Name: adrian reinhard
Contact:

Re: New VEEAM backup job script

Post by adrian138 » 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

veremin
Product Manager
Posts: 16989
Liked: 1452 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: New VEEAM backup job script

Post by veremin » Nov 14, 2018 4:03 pm

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: 35
Liked: 2 times
Joined: Oct 17, 2018 9:01 am
Contact:

Re: New VEEAM backup job script

Post by karim » Nov 15, 2018 9:36 am

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 1 guest