VMware Mirage - SQL query to get missing layers on Volume

Sometime, you want to be sure that all the layers are already copied to some volume in VMware Mirage. In case of futur deployement, you ensure that as all layers are already copied, the provisionning procedure will go faster.

You can use the provided tools to do this, but it can run into issues:
"C:\Program Files\Wanova\Mirage Management Server\Wanova.Server.Tools.exe" CloneBiTool -serverAddress -cloneAllLayers -volumeName="Mirage Volume 1"

The problem with this command is that Mirage will copy every missing layers to the target volume "Mirage Volume 1", so if there is 200 layers missing on this volume, Mirage will try to copy all in one piece. If you have a high latency storage, this can fail because IOPS on the volume is not enough sustained to handle all the read/write. You will retrive a "malfunction" volume in Mirage

So you probably want to copy layers by little group of 5 per example.
To achieve that,you need to know wich layers are missing on a particular volume.
You can get these missing layers with this SQL query in SQL Studio:

 ,'Mirage Volume 1' VolumeName
FROM BaseImage
SELECT baseImage_id
JOIN BaseImage_Volume
ON Volume.ID = BaseImage_Volume.volume_id
WHERE Volume.Name = 'Mirage Volume 1'
AND Name NOT LIKE '%Removed_on%'
ORDER BY BIID, MajorVersion, MinorVersion
You need to replace the 'Mirage Volume 1' with your volume name.
After the query run, you will retrieve BIID, Major and Minor version missing on this volume.
You have to create a CSV file with Notepad++ for example with this kind of content:
You have to respect the header name of the CSV, the file must be without extra blank line.
Then you can run this command to only copy the layers mentionned in the CSV file:
"C:\Program Files\Wanova\Mirage Management Server\Wanova.Server.Tools.exe" CloneBiTool -serverAddress -LayersFile C:\Batches\mirage\clone\layers.csv -volumeName "Mirage Volume 1" 
Here are my advices:

  1. copy Base Layers image alone, adding other layers could also fail because BaseLayer copy is IO intensive
  2. depending of your storage, start copy with group of 5 and try to increase slowly. if prefer 5 layers copied successfully than 20 where the 18th has failed...
  3. run the wanova.server.tools.exe under the account of mirage service
  4. be patient, i always fail when i want to copy too much layers in one time. no timed saved because when a copy failed, you will have to clean the database by hand to cancel orpahn tasks...