I need to implement a backup solution for virtual machines runnin on Windows Server 2008 R2 using Powershell and PSHyperV module. The module helps loads, as it provides an easy way to get VM properties and other stuff, perform basic functions, etc.
I plan for the least downtime scenario, as the VMs in question are potentially used by clients, and they usually don't tolerate any downtime. I am aware that using Windows Server 2012 R2 hypervisor solves this problem altogether because it has live VHD merge functionality, but migration of infrastructure is a long enough process and backups don't wait.
Currently, the backups are done via save VM -> copy tree -> start VM
process, which involves up to 6h downtime for the biggest VM. I am planning to use VM snapshots to lessen the downtime, as once you have performed a snapshot, you can back up the VHDs and the snapshot data elsewhere without disturbing the VM (it'll be slower, but that's all). Then I plan to save the VM, remove the snapshot (VHD merge will occur), wait until merging will complete, then start the VM, potentially reducing the VM downtime to half an hour worst case.
So far my script is able to locate VHDs of a given VM, back them up, but is unable to find the VM's snapshots location. It is possible that just traversing the tree from VHDs folder backwards will not yield me neither "Virtual Machines" nor "Snapshots" folder, so guessing is out of option.
How do I get the location of snapshot files in order to do a manual export for the VM snapshot?