Exclusion of viEntity

PowerShell script exchange

Exclusion of viEntity

Veeam Logoby Tobias_Elfstrom » Wed Nov 21, 2012 8:29 am

I base my backups on the the folder's my VM are in but i would like to do exlusions based on clusters.

This is how I create the base of a backupupb:
Code: Select all
Add-VBRViBackupJob -Name $JobName -BackupRepository $JobRepository -Entity (Find-VBRViEntity -VMsAndTemplates -Name $FolderName)


I end up with a job with objects like this:
Code: Select all
PS V:\Temp\Tobias\vmbackup01\scripts> Get-VBRJobObject -Job $job


Id                  : 509e1414-f848-4f3a-a3c9-40b8a3a70d7b
Object              : Name: AI010
Filter              :
Name                : AI010
Type                : Include
Location            : vcloudserver\IDC\Production\AI010
ApproxSizeString    : 198,7 GB
Info                : Veeam.Backup.Model.CDbObjectInJobInfo
JobId               : fe76f8f0-84c3-46d0-94bd-9fcfbe43be58
IsFolder            : False
IsIncluded          : True
IsVssChild          : False
IsExcludeDisksChild : False
IsExcluded          : False
IsExtended          : False
PolicyType          : None
VssOptions          : <CVssOptions><Enabled>True</Enabled><IgnoreErrors>False</IgnoreErrors><GuestFSIndexingType>ExceptSpecifiedFolders</GuestFSIndexingType><Transaction
                      LogsTruncation>OnlyOnSuccessJob</TransactionLogsTruncation><IsFirstUsage>True</IsFirstUsage><IncludedIndexingFolders /><ExcludedIndexingFolders><st
                      ring>%windir%</string><string>%ProgramFiles%</string><string>%TEMP%</string></ExcludedIndexingFolders></CVssOptions>
ExtendedOptions     : Veeam.Backup.Model.COijExtendedOptions
DiskFilter          : 2000;2001;2002;2003;2004;2005;2006;2008;2009;2010;2011;2012;2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2024;2025;2026;2027;2028;2029;2030;20
                      31;2032;2033;2034;2035;2036;2037;2038;2040;2041;2042;2043;2044;2045;2046;2047;2048;2049;2050;2051;2052;2053;2054;2056;2057;2058;2059;2060;2061;2062
                      ;2063
UpdateConfig        : True
Role                : EInclude



I can find the cluster I want to exclude by doining:
Code: Select all
Find-VBRViEntity -HostsAndClusters -Name $ClusterName


Howerver I find no way to exluding this from powershell. I can exclude it in the GUI and end up with a job like this:

Code: Select all
PS V:\Temp\Tobias\vmbackup01\scripts> Get-VBRJobObject -Job $job


Id                  : 509e1414-f848-4f3a-a3c9-40b8a3a70d7b
Object              : Name: AI010
Filter              :
Name                : AI010
Type                : Include
Location            : vcloudserver\IDC\Production\AI010
ApproxSizeString    : 198,7 GB
Info                : Veeam.Backup.Model.CDbObjectInJobInfo
JobId               : fe76f8f0-84c3-46d0-94bd-9fcfbe43be58
IsFolder            : False
IsIncluded          : True
IsVssChild          : False
IsExcludeDisksChild : False
IsExcluded          : False
IsExtended          : False
PolicyType          : None
VssOptions          : <CVssOptions><Enabled>True</Enabled><IgnoreErrors>False</IgnoreErrors><GuestFSIndexingType>ExceptSpecifiedFolders</GuestFSIndexingType><Transaction
                      LogsTruncation>OnlyOnSuccessJob</TransactionLogsTruncation><IsFirstUsage>True</IsFirstUsage><IncludedIndexingFolders /><ExcludedIndexingFolders><st
                      ring>%windir%</string><string>%ProgramFiles%</string><string>%TEMP%</string></ExcludedIndexingFolders></CVssOptions>
ExtendedOptions     : Veeam.Backup.Model.COijExtendedOptions
DiskFilter          : 2000;2001;2002;2003;2004;2005;2006;2008;2009;2010;2011;2012;2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2024;2025;2026;2027;2028;2029;2030;20
                      31;2032;2033;2034;2035;2036;2037;2038;2040;2041;2042;2043;2044;2045;2046;2047;2048;2049;2050;2051;2052;2053;2054;2056;2057;2058;2059;2060;2061;2062
                      ;2063
UpdateConfig        : True
Role                : EInclude

Id                  : ca3df141-6cfc-4bd6-9cde-a25742ee9832
Object              : Name: vCluster 1
Filter              :
Name                : vCluster 1
Type                : Exclude
Location            : vcloudserver\vCluster 1
ApproxSizeString    : 37,5 TB
Info                : Veeam.Backup.Model.CDbObjectInJobInfo
JobId               : fe76f8f0-84c3-46d0-94bd-9fcfbe43be58
IsFolder            : False
IsIncluded          : False
IsVssChild          : False
IsExcludeDisksChild : False
IsExcluded          : True
IsExtended          : False
PolicyType          : None
VssOptions          : <CVssOptions><Enabled>True</Enabled><IgnoreErrors>False</IgnoreErrors><GuestFSIndexingType>ExceptSpecifiedFolders</GuestFSIndexingType><Transaction
                      LogsTruncation>OnlyOnSuccessJob</TransactionLogsTruncation><IsFirstUsage>True</IsFirstUsage><IncludedIndexingFolders /><ExcludedIndexingFolders><st
                      ring>%windir%</string><string>%ProgramFiles%</string><string>%TEMP%</string></ExcludedIndexingFolders></CVssOptions>
ExtendedOptions     : Veeam.Backup.Model.COijExtendedOptions
DiskFilter          : 2000;2001;2002;2003;2004;2005;2006;2008;2009;2010;2011;2012;2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2024;2025;2026;2027;2028;2029;2030;20
                      31;2032;2033;2034;2035;2036;2037;2038;2040;2041;2042;2043;2044;2045;2046;2047;2048;2049;2050;2051;2052;2053;2054;2056;2057;2058;2059;2060;2061;2062
                      ;2063
UpdateConfig        : True
Role                : EExclude


If I try to use the Remove-VBRJobObects it complains about the wrong datatype:
Code: Select all
Remove-VBRJobObject -job $job -Objects (Find-VBRViEntity -HostsAndClusters -Name $clustername)
[color=#FF0000]Remove-VBRJobObject : Cannot bind parameter 'Objects'. Cannot convert the "Veeam.Backup.Core.Infrastructure.CViClusterItem" value of type "Veeam.Backup.Core.Infrastructu
re.CViClusterItem" to type "Veeam.Backup.Core.CObjectInJob".[/color]


And I cant find any Remove-VBRViObjects..

Anyone have any hints on how to do this?
Tobias_Elfstrom
Enthusiast
 
Posts: 84
Liked: 8 times
Joined: Wed Jul 04, 2012 6:32 am
Full Name: Tobias Elfstrom

Re: Exclusion of viEntity

Veeam Logoby ThomasMc » Thu Nov 22, 2012 1:40 pm

Look at line 11 over at

http://vpowercli.wordpress.com/2012/01/ ... -in-a-job/

That should get you able to finish your script :)
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: Exclusion of viEntity

Veeam Logoby Tobias_Elfstrom » Fri Nov 23, 2012 5:41 am

ThomasMc wrote:Look at line 11 over at

http://vpowercli.wordpress.com/2012/01/ ... -in-a-job/

That should get you able to finish your script :)


Thanks but the problem is that I would rather exclude a vi object, in my case a cluster, rather than a VM.

I could do something like this between every iteration of the job:
Code: Select all
function update-job {
    Param {$JobName, $FolderName, $Cluster}
    $VMNames = get-vm -Location $FolderName | Where-Object {(get-cluster -VM $_.name).name -ne $Cluster}
    Get-VBRJobObject -job $JobName |Remove-VBRJobObject -Job $JobName
    Add-VBRJobObject -Job $JobName -Entity (Find-VBRViEntity -Name $VMNames)
}


But what I would like is to have dynamic jobs without having to run scripts over and over again.
Tobias_Elfstrom
Enthusiast
 
Posts: 84
Liked: 8 times
Joined: Wed Jul 04, 2012 6:32 am
Full Name: Tobias Elfstrom

Re: Exclusion of viEntity

Veeam Logoby v.Eremin » Fri Nov 23, 2012 7:45 am

Yep, we’ve discussed the issue of exclusion vm-objects coming from particular cluster with Tobias through PM.

His idea is represented above. And I was along the same line with him, going to propose some script that in cycle would check name of cluster of vm-object and name of specified cluster for coincidence. In case it happened, it would remove this vm-object.

Our intensions to find any other solutions apart from the ones already mentioned came a cropper.

So, any suggestions would be highly-appreciated.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Exclusion of viEntity

Veeam Logoby ThomasMc » Fri Nov 23, 2012 1:05 pm

Good luck :)
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: Exclusion of viEntity

Veeam Logoby Tobias_Elfstrom » Fri Nov 23, 2012 1:46 pm

ThomasMc wrote:Good luck :)

Ha, yeah... thanks :D
Tobias_Elfstrom
Enthusiast
 
Posts: 84
Liked: 8 times
Joined: Wed Jul 04, 2012 6:32 am
Full Name: Tobias Elfstrom

Re: Exclusion of viEntity

Veeam Logoby tsightler » Fri Nov 23, 2012 5:35 pm 2 people like this post

Hey guys, you might want to look at this thread. While the thread in question is specifically about adding and using folders, the concept could be easily modified to work for clusters. Basically, you would use a small modification of the "unsupported" code on that page to get the ViSoap object, add it to the job, get the "JobObject" and then using the Remove-VBRJobObject cmdlet to exclude it. If I get a few minutes I can try to piece together the changes needed to get clusters instead of folders.
tsightler
Veeam Software
 
Posts: 4772
Liked: 1739 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Re: Exclusion of viEntity

Veeam Logoby Tobias_Elfstrom » Fri Nov 23, 2012 6:09 pm

Wonderful! Thanks a bunch for pointing me in the right direction, even if it is unsupported.
Tobias_Elfstrom
Enthusiast
 
Posts: 84
Liked: 8 times
Joined: Wed Jul 04, 2012 6:32 am
Full Name: Tobias Elfstrom

Re: Exclusion of viEntity

Veeam Logoby tsightler » Sat Nov 24, 2012 8:40 pm 1 person likes this post

Just to put it all together in one place:

Code: Select all
$vCenter = Get-VBRServer -Name "<Your_vCenter_Server>"
$Job = Get-VBRJob -Name "<Job_to_Edit>"
$ExCluster = "<Cluster_to_Exclude_from_Job>"

# Populate the top of the Host and VMs Entity View
$HaV = ((New-Object -typename Veeam.Backup.Core.InfrastructureTree.HostsAndClustersLoader).LoadHierarchy($vCenter.Info)).HostsAndVms()

# Find the Object for the Cluster that is being excluded
$ExClusterObj = Find-VBRViEntity -server $vCenter -HostsandClusters -Name $ExCluster

#Call GetChild method to perform a recursive search on the $HaV view to find the cluster ViSoap Entity required by Add-VBRJobObject
$ExClusterEntity = $HaV.GetChild($ExClusterObj.Reference, "ClusterComputeResource", $true)

#Add Cluster Entity to the job
Add-VBRJobObject -Job $Job -Server $vCenter -Entities $ExClusterEntity

#Get the Cluster Job Object now that it has been added to the job
$ExClusterJobObject = Get-VBRJobObject -Job $Job | Where-Object {$_.Object.ObjectId -eq $ExClusterEntity.Id }

#Exclude the Cluster Object from the job
Remove-VBRJobObject -Job $Job -Objects $ExClusterJobObject

#Delete the Included Cluster Job Object (Only the Excluded Cluster Object will remain)
$ExClusterJobObject.Delete()


The code above is intentionally wordy to demonstrate the concept. Much thanks must go to Seth for first showing how to use the LoadHierarchy function. This is the only function that is "unsupported" and since it's not really doing anything special other than populating the ViSoap view so that we can find the right objects there's no real risk in using it other than the implementation might change in the future.
tsightler
Veeam Software
 
Posts: 4772
Liked: 1739 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Re: Exclusion of viEntity

Veeam Logoby arnoutv » Fri Oct 04, 2013 10:06 am

Is there a vCloud solution for this?

I'm having the same kind of trouble:
I can create a job to back-up a full vCloud organization, and use find-VBRVCloudEntity to find a VM to exclude, but the Remove-VBRJobObject won't accept it as a param.
Once get-VBRBackup does return something, I could use the .getObjects() method, but the problem is: For a freshly created Job get-VBRBackup doesn't return anything...

The GUI does allow navigating vCkloud to add exclusions, so there must be an infrastructure tree functionality somewhere in all that DLL's right?
arnoutv
Lurker
 
Posts: 2
Liked: never
Joined: Thu Oct 03, 2013 8:42 am
Full Name: A Vreugdenhil

Re: Exclusion of viEntity

Veeam Logoby arnoutv » Fri Oct 04, 2013 1:57 pm

Got it!

The Find-VBRvCloudEntity doesn't return objects of the type CEntity, so the regular commandlets won't accept it.
It does return IItem objects, and those can be added and excluded in this manner:

Code: Select all
$VMName = 'someVM'

# need extra checks to see if it's the right org and vApp to ensure it's the right VM
$vm = Find-VBRVcloudEntity -Name $VMName

#prepare the [ref] params
$added = $tplfailed = $faultTolerantFailed = $incompatFailed = $alreadyThere = $null
#add it
[Veeam.Backup.Core.Infrastructure.CJobItemsHelper]::TryAddItemsToJob( $job, $vm, [ref] $added, [ref] $tplfailed, [ref] $faultTolerantFailed, [ref] $incompatFailed, [ref] $alreadyThere )
#check the [ref] vars!

# flipt he added VM to negate
$jo = get-VBRJobObject -Job $job.Name -Name $vm.ViVmName
$jo.Info.Type = 'Exclude'
[Veeam.Backup.Core.CObjectInJob]::Update( $jo.Info )
arnoutv
Lurker
 
Posts: 2
Liked: never
Joined: Thu Oct 03, 2013 8:42 am
Full Name: A Vreugdenhil

Re: Exclusion of viEntity

Veeam Logoby Anders » Tue Aug 25, 2015 2:01 pm

We have a VMWare tag called "No-Backup" that we want to add as an exclusion on all our backup jobs. I got to see the same issues as the OP had type issues.

Are there any changes regarding this in V8?

If not, how would I script this with Tags instead of a Cluster as the solution example is for?

Thanks,
Anders
Anders
Enthusiast
 
Posts: 36
Liked: 7 times
Joined: Thu Sep 09, 2010 9:45 am
Full Name: Anders Lorensen

Re: Exclusion of viEntity

Veeam Logoby tsightler » Tue Aug 25, 2015 2:23 pm

This thread is quite old and most of the limitations no longer apply. It's possible to exclude tags via Powershell using supported cmdlets. An example is available in this thread.
tsightler
Veeam Software
 
Posts: 4772
Liked: 1739 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler


Return to PowerShell



Who is online

Users browsing this forum: robbysmith and 7 guests