New in v11: combine vSphere tags


Userlevel 7
Badge +4

@PValsecchi already showed how to use vSphere tags for VM selection in VBR. New in v11 is the possibility to combine vSphere tags. I want to show how this work.

 

For that, I created two tag categories. One for Location and one for Backup. I defined datacenter A and B locations; and Gold, Silver and Bronze backup priority.

 

These tags are assigned to my 4 test VMs:

So: VM01 and VM03 (odd numbers) are located in DC A. VM02 and VM04 (even numbers) are in DC B. VM01 and VM02 are defined for Gold-Backup, VM03 for Silver, VM04 for Bronze.

 

First, I select one Tag for VM selection: DC A. This can be done either with single tag selection or with new combination of tags but just select one.

As expected, when backup runs, VM01 and VM03 are selected:

Next, I want to backup all Gold-Backup VMs in DC B and select these tags:

 

Objects shown in Job definition:

Just VM02 has all tags assigned:

 

Fine, works as expected! And now, backup all VMs in DC A and B:

Eventually here is a pitfall. Because now nothing will be backed up:

 

Simple because no VM can be in DC A and B simultaneously - at lease not with the definition of my tags. To backup all DC A and B VMs, select single tags as usually:

All VMs in both DCs are selected:

Important: at the moment just AND combinations are supported


12 comments

Userlevel 7
Badge +3

This is a fine way to define a structure for automatic selection of VMs to Jobs. Great extension of this functionality.

Is there a mechanism in VMWare to be sure that the tags have to be set at the creation of a VM? Otherwise the admins will forget it for most of the maschines… :smiley:

Userlevel 7
Badge +3

This is great, and thanks for breaking down the logic of the tag combination as you did, it was great to see that example of selecting both DCs!

Userlevel 7
Badge +2

@JMeixner: I don’t know any. But as a workaround you could create a catch-all job, which backups only VMs without tags. Or create a scheduled PowerCLI script which reports VMs without tags or assigns a default tag to those.

Seeing the example with the two DCs I fear that this can easily happen and result in missing backups. Double checking or reporting will be a must if using tag combinations.

Userlevel 7
Badge +4

Yes it is quite easy to query for not-tagged VMs. Simple like this:

$NotTaggedVMs = @()
Get-VM | ForEach-Object {if((Get-TagAssignment $_) -eq $null) {$NotTaggedVMs += $_}}

I normally start such a script scheduled. It could tag VMs or report per mail. 

Userlevel 7
Badge +4

@JMeixner Actually there is solution for this: VMware Event Broker Appliance. It is currently a fling (no support) that is still in development. Just a few days ago, version 0.5 was released. It uses a new approach: Event driven automation. In this example, a tag is assigned to a new VM, when the event of VM-creation appears.

I personally believe, this will be part of vSphere one day.

Userlevel 7
Badge +3

Thank you for the code snippet, @vNote42 

And the hint to the Event Broker Appliance is great, too. I will suggest ths to our VMWare Admins.

Userlevel 7
Badge +2

The VMware Event Broker Appliance sounds great! Will need to test this out soon.

Userlevel 7
Badge +4

The VMware Event Broker Appliance sounds great! Will need to test this out soon.

Please share your experiences here. :grin:

Userlevel 7
Badge +3

The VMware Event Broker Appliance sounds great! Will need to test this out soon.

+1 on this, every day’s a school day!

Userlevel 7
Badge +4

The VMware Event Broker Appliance sounds great! Will need to test this out soon.

+1 on this, every day’s a school day!

And almost every day is too short ...

Userlevel 6
Badge +2

Yes it is quite easy to query for not-tagged VMs. Simple like this:

$NotTaggedVMs = @()
Get-VM | ForEach-Object {if((Get-TagAssignment $_) -eq $null) {$NotTaggedVMs += $_}}

I normally start such a script scheduled. It could tag VMs or report per mail. 

This will help me for sure

Userlevel 6
Badge +2

Thanks a lot for the wonderful write-up. I always encourage people to use TAGs as it's a brilliant way to manage your VMs and your backups. I also tend to TAG the VMs that require Copy/Replication as normally we don't replicate/Copy everything to DR. 

Comment