February 9, 2013

TIP: Backup Lync Server VM (Windows Server 2012 Hyper-V PowerShell)

As part of disaster recovery / business continuity plan (DR/BCP) in your Hyper-V virtualized Lync Server 2013/2010 infrastructure, it is imperative as best practice dictates to verify that the plans, procedures, logistics, etc. among others, work before Murpfy’s law gets to kick in.

In Windows Server 2012 Hyper-V, virtual machine management has been greatly enhanced with extensive PowerShell v3 cmdlets support in the Hyper-V module. To that end, you can make backup copies of key virtualized Lync server roles (VMs) encapsulated in VHD/VHDX and the supporting files. This is achieved using the Export-VM cmdlet although a prior run is no longer essential in Windows Server 2012 (before a VM can be imported based on the presence of .exp export file).

Unlike the “Import Virtual Machine” action in the Hyper-V Manager GUI where you specify the base folder of the source VM folder structure for import in Hyper-V (Windows Server 2012), you should supply instead the full path to the actual XML file* against the -Path parameter of the Import-VM cmdlet i.e.

Import-VM -Copy -Path “C:\vm\LyncFE01\Virtual Machines\xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.xml”

Next to -Copy, the -GenerateNewId parameter comes in handy should you want to avoid conflict with the existing running Lync VM instance, either in the same production network or in a lab environment.

You may, however, encounter similar self-explanatory errors as listed e.g. wrong XML:

Import-VM : Failed to import a virtual machine.
The operation cannot be performed while the object is in use.
At line:1 char:1
+ Import-VM -Copy -Path “C:\vm\LyncFE01\Virtual Machines\xxxxxxxx-xxxx-xxx …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ResourceBusy: (Microsoft.HyperV.PowerShell.VMTask:VMTask) [Import-VM], VirtualizationOperationFailedException
+ FullyQualifiedErrorId : ObjectInUse,Microsoft.HyperV.PowerShell.Commands.ImportVMCommand


Import-VM : The Virtual Machine Management Service on host ‘HyperV3′ is not running.
At line:1 char:1
+ Import-VM -Copy -Path “C:\vm\LyncFE01\Virtual Machines\xxxxxxxx-xxxx-xxx …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Import-VM], VirtualizationOperationFailedException
+ FullyQualifiedErrorId : Microsoft.HyperV.PowerShell.Commands.ImportVMCommand


Import-VM : Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
At line:1 char:1
+ Import-VM -Copy -Path “C:\vm\LyncFE01\Virtual Machines\xxxxxxxx-xxxx-xxx …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Import-VM], FormatException
+ FullyQualifiedErrorId : Unspecified,Microsoft.HyperV.PowerShell.Commands.ImportVMCommand

If you did not indicate otherwise, Hyper-V will attempt to perform the import with default data placement of the “Virtual machine configuration folder”, “Snapshot store” and “Smart Paging folder”, all of which reside typically in the “C:\ProgramData\Microsoft\Windows\Hyper-V\” folder.

Now, even though -VhdDestinationPath is marked as obsolete in the Import-VM PowerShell v3 Help, you will want to use it anyway if target disk space is insufficient (as the -VirtualMachinePath help info is incomplete and does not appear to function):

PS C:\Users\Administrator> Import-VM -Copy -Path “C:\vm\LyncFE01\Virtual Machines\xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.xml” -VirtualMachinePath “D:\vm\LyncFE01″ -GenerateNewId

Import-VM : There is not enough space on the disk.
At line:1 char:1
+ Import-VM -Copy -Path “C:\vm\LyncFE01\Virtual Machines\xxxxxxxx-xxxx-xxx …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (:) [Import-VM], IOException
+ FullyQualifiedErrorId : DeviceNotFound,Microsoft.HyperV.PowerShell.Commands.ImportVMCommand

This is because the imported virtual hard disks will be saved as standard in the “C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\” folder.

A successful import of the Lync VM should be greeted with:

PS C:\Users\Administrator> Import-VM -Copy -Path “C:\vm\LyncFE01\Virtual Machines\xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.xml” -VhdDestinationPath “D:\vm\LyncFE01″ -GenerateNewId

Name    State CPUUsage(%) MemoryAssigned(M) Uptime   Status
—-    —– ———– —————– ——   ——
HyperV3 Off   0           0                 00:00:00 Operating normally

* typically located in the “Virtual Machines” sub-folder

Technorati tags: PowerShell, Windows Server 2012/Windows Server 8, Hyper-V, Cloud Computing, Microsoft Lync Server/Client /Lync Phone Edition / Lync Mobile

1 Comment »

  1. […] TIP: Backup Lync Server VM (Windows Server 2012 Hyper-V PowerShell) – 9-Feb-2013 […]

    Pingback by NeWay Technologies – Weekly Newsletter #30 – February 14, 2013NeWay | NeWay — February 16, 2013 @ 11:56 pm

RSS feed for comments on this post. | TrackBack URI

Leave a comment

You must be logged in to post a comment.

Theme Designed by: Malone Car Hire Ireland