Hyper-V on CSV may be protected with the diskshadow command with the script parameter and a script file specified. The diskshadow script file initiates the snapshot of the CSV volume, executes a second script, and then releases the VSS CSV snapshot. The second script executed by the diskshadow script mounts the snapshot or snapshots, runs the DATASTOR protection plan to protect the mounted snapshot, then removes the mounted snapshots.


There are three scripts and a protection plan involved in the configuration and backup of Hyper-V virtual machines hosted on a cluster shared volume at the C:\ClusterStorage location.


  1. diskshadow-hypervcsv.ps1 is executed once from a powershell command prompt on the ownership node of the failover cluster to build a diskshadow  script that provides parameters to the diskshadow backup utility. The script is named hypervcsvscript.txt, that contains a set of diskshadow commands to generate a VSS snapshot of the ClusterStorage volumes on the server using the 'Microsoft Hyper-V VSS Writer' with Writer Id {66841cd4-6ded-4f4b-8f17-fd23f8ddc3de} and the 'Microsoft CSV Shadow Copy Provider' with Provider Id  {400a2ff4-5eb1-44b0-8a05-1fcac0bcf9ff}. If the cluster later has another cluster shared volume added to it, this powershell script must be run again to generate a new hypervcsvscript.txt file to include the added volume.
  2. C:\hypervbackup\hypervcsvscript.txt is the result of running diskshadow-hypervcsv.ps1. The command 'diskshadow -s C:\hypervbackup\hypervcsvscript.txt' is scheduled to run as a scheduled task. It invokes the diskshadow utility and the hypervcsvscript.txt script contains the diskshadow commands.

    Note: the script creates a snapshot of the CSV volume or volumes that host Hyper-V virtual machines but it does not back up other associated Hyper-V files located on the C: drive.

    The diskshadow utility supports the 'exec' command that allows a second script to be invoked within the hypervcsvscript file. The hypervcsvscript.txt script includes an exec command to invoke aiqremote.cmd, which mounts the shadowcopy, runs the DATASTOR protection plan, and then unmounts the shadowcopy. After the exec command completes, the script ends the backup, which deletes the volatile snapshot.
  3. aiqremote.cmd is invoked by the diskshadow hypervcsvscript.txt script to mount the shadowcopy, run the protection plan, and then unmount the shadowcopy. If the cluster later has another cluster shared volume added to it, this script must be updated to mount and unmount the added volume.
  4. A Files and Folders protection plan is created as a remote computer protection plan, specifying the C:\hypervbackup directory or sub directories. It is not scheduled to run in Archive Manager. It specifies the -nosnap parameter. 


It may be possible to improve the powershell script so the script creates both the hypervcsvscript.txt file and the aiqremote.cmd file with the cluster shared volume information. The script may be scheduled to run regularly to automatically pick up any new volumes. The protection plan would still have to be manually updated.



To protect Hyper-V virtual machines in CSV configuration:

Run: diskshadow -s C:\hypervbackup\hypervcsvscript.txt


C:\hypervbackup\hypervcsvscript.txt commands are based on your specific cluster node. In this example it contains:

   
    set verbose on  
    set context volatile  
    set metadata c:\hypervbackup\hypervcsv.cab
    begin backup  
    writer exclude {d61d61c8-d73a-4eee-8cdd-f6f9786b7124}
writer exclude {75dfb225-e2e4-4d39-9ac9-ffaff65ddf06}
writer exclude {0bada1de-01a9-4625-8278-69e735f39dd2}
writer exclude {e8132975-6f93-4464-a53e-1050253ae220}
writer exclude {1072ae1c-e5a7-4ea1-9e4a-6f7964656570}
writer exclude {be000cbe-11fe-4426-9c58-531aa6355fc4}
writer exclude {8d5194e1-e455-434a-b2e5-51296cce67df}
writer exclude {4dc3bdd4-ab48-4d07-adb0-3bee2926fd7f}
writer exclude {2a40fd15-dfca-4aa8-a654-1f8c654603f6}
writer exclude {afbab4a2-367d-4d15-a586-71dbb18f8485}
writer exclude {a65faa63-5ea8-4ebc-9dbd-a0c4db26912a}
writer exclude {542da469-d3e1-473c-9f4f-7847f01fc64f}
writer exclude {35e81631-13e1-48db-97fc-d5bc721bb18a}
writer exclude {a6ad56c2-b509-4e6c-bb19-49d8f43532f0}
writer exclude {41e12264-35d8-479b-8e5c-9b23d1dad37e}
add volume C:\ClusterStorage\Volume1 PROVIDER {400a2ff4-5eb1-44b0-8a05-1fcac0bcf9ff} ALIAS Volume1
add volume C:\ClusterStorage\Volume2 PROVIDER {400a2ff4-5eb1-44b0-8a05-1fcac0bcf9ff} ALIAS Volume2
create
exec "c:\hypervbackup\aiqremote.cmd"
End Backup

___________________

aiqremote.cmd should be edited according to your specific cluster volumes and DATASTOR plan id. In this example it contains:


mklink /d c:\temp\csvlink1 \\?\GLOBALROOT\Device\CSV%Volume1%\

mklink /d c:\temp\csvlink2 \\?\GLOBALROOT\Device\CSV%Volume2%\

\\datastor-01\aiqremote$\ArchiveIQLaunch.exe *aiqremote -config "\\datastor-01\aiqremote$\Configurations\{77c9de71-41b5-4fa6-881c-a8c221717011}.pln"

rmdir c:\temp\csvlink1

rmdir c:\temp\csvlink2

____________________

The aiqremote.cmd file references a protection plan. The protection plan was created through Archive Manager. It is Files and Folders type plan, and selects the temp folder for backup, with no snap set.