Friday, December 4, 2015

ESXi 6.0 - CBT bug and fix(fix VMs and reset CBT) Part II

Continuing the ESXi 6.0 CBT(Change Block Tracking) issue, so that backups and restore can work properly, CBT needs to be reset. This is a mandatory task that needs to be done to all VMs that are in the Backups jobs. Regardless of the Backup tool you use to backup your VMware environment.

Again, in our case we use Veeam and Veeam has a script that will reset CBT in all VMs that are poweron and with no spanshots on it(power off VMs and with Spashots will be excluded from the list of VMs that will have the CBT reset).

What is consisting this CBT fix in the VMs(regardless the Guest OS). This will reset the CBT so that backups can start from zero and have a proper consistence in the incremental backups.

Tasks performed by this script:

•    Disable CBT in the VM
•    Create a VM snapshot
•    Remove VM Snapshot
•    Enable CBT in the VM

We can download the Veeam script HERE

But in our case there was an issue with a code line in that script. Script could not identify VMs with the CBT enabled. VMs list was null.

After create a small and simple scirpt to test CBT enable, or disable in a VM I found the problem Veeam script.

This is my script:
$VMCBT = Get-Cluster "Cluster Test" | get-vm 

foreach ($VMCBTs in $VMCBT){

if ($VMCBTs | where {$_.ExtensionData.config.ChangeTrackingEnabled -eq $true}){
 Write-Host ($VMCBTs.Name) ' CTB Enable'

 } else { Write-Host ($VMCBTs.name)  ' CBT is disable'}
 }
 In Veeam script found the issue in this line:
$ivms = get-vm | ?{$_.ExtensionData.Config.ChangeTrackingEnabled -eq $true};
With this $ivms always returns null, since there was no condition to check if VM had CBT enabled, or not.

So add a where condition to the line, fix the issue and all VMs with CBT enabled were listed.
$ivms = Get-Cluster "Cluster Test" | get-vm | where ' {$_.ExtensionData.config.ChangeTrackingEnabled -eq $true};
Since I will run the script by Cluster and not in all vCenter, I add also the Get-Cluster option.

Hope this helps you to fix your CBT on your VMs also.

No comments:

Post a Comment