vRanger: Bulk enable Change Block Tracking (CBT) on virtual machines

Change Block Tracking (CBT) is a VMkernal feature that records the blocks of a virtual machine as they change over time (since the last backup). This enhances the backup process as it reduces the time and size of the backup job, especially when accompanied with Active Block Mapping (ABT).

By default, virtual machines do not have CBT tracking available within vRanger. This may be enabled for a single virtual machine from the GUI and selecting Enable Change Tracking. However, this may be time consuming for a large number of virtual machines. This is where the vRanger cmd-lets come into play.

Firstly, CBT many only be enabled on virtual machines where the hardware version is 7. If you have vSphere PowerCLI installed you can determine the virtual machines which do not meet this requirement by running the below:

Get-VM | Get-View | Where-Object {$_.Config.Version -ne “vmx-07”} | Select Name

Once the virtual machines have been upgraded (or you may decide not to upgrade) you will now want to enable CBT on these virtual machines as a bulk process. There is a number of entities we can use from the vRanger console using the ‘Get-InventoryEntity’ cmd-let and specifying the Type (-Type parameter).

In this example we will be using the virtualmachine as the Type parameter to enable CBT for all virtual machines. Firstly, we will return all virtual machines into a variable:

$vm = Get-InventoryEntity -Type virtualmachine

For each item we will pipe this into the ForEach object and loop through each virtual machine to Enable CBT

foreach ($i in $vm) { Set-CBTonVM -VM $i -CBT 1}

The CBT parameter of ‘1’ enables CBT and ‘0’ disables CBT for that virtual machine.

You can combine the above with our first part of checking to see if the virtual machine hardware version is compatible with CBT and then enabling CBT for those virtual machines using the following (This will require vSphere PowerCLI and vRanger Pro Console snap-ins to be installed and loaded) by using the following script:

$vm = Get-VM | Get-View | Where-Object {$_.Config.Version -eq “vmx-07”}

foreach ($i in $vm) { Set-CBTonVM -VM $i -CBT 1}

For more information on CBT and ABT see the vRanger User Guide (page 103) see, http://worlddownloads.quest.com.edgesuite.net/Repository/support.quest.com/vRanger/5.2/Documentation/vRanger_5.2_UserGuide.pdf

2 thoughts on “vRanger: Bulk enable Change Block Tracking (CBT) on virtual machines

  1. This is a good start but the code presented will not work. The VM information gathered from the GET-VM is incompatable with the VMentity needed for Set-CBTonVM

    Here’s some code that will do the job:

    $VMNames = Get-VM | Get-View | Where-Object {$_.Config.Version -eq ‘vmx-07’} | Select Name

    $VMs = Get-InventoryEntity -Type virtualmachine

    $VMs | where { $VMNames -match $_.Name } | foreach {write-output $( “Setting ” + $_.Name); Set-CBTonVM -VM $_ -CBT 1}


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s