Using Azure IaaS is great, but like all IaaS solutions it still requires some administrative efforts. In my last installment, I detailed how to use Windows Azure backup and recovery services to protect data contained in virtual machines and how to monitor the success of the backup operations with System Center Operations Manager (https://nocentdocent.wordpress.com/2014/03/01/windows-azure-backup-agent-monitoring-with-sysctr-scom-2/). Protecting data is only one of the aspects for a complete data protection solution, a complete virtual machine corruption it’s not addressed by data protection. Since we don’t have access to host based backup a common strategy is to create a clone of the virtual machine’s disks.
In Azure this needs to be accomplished stopping the virtual machine and copying the virtual disks, the high-level steps are:
Stop the VM
Identify and copy the OS disk
Identify and copy the Data disks
Restart the VM
Obviously when drilling into the single steps things are a little more complicated; fortunately, Windows Azure has a complete SDK and a powershell module that can be leveraged.
This post presents a powershell module to accomplish this task hiding all the complexities underneath a single easy call. The module exposes a Backup-AzureVM function. The function works under the following assumptions:
The powershell module has been imported
The current subscription hosts the VM to be backed up
The current subscription hosts the storage account used for the backup copies
The final result is a copy of the VM disks, optionally including data disks. The backup disks will be time stamped following this schema: <vm name>-<yyyyMMdd>-<HHmm>-<original blob name>
The function takes the following parameters:
– ServiceName – name of the Azure service hosting the VM
– VMName – name of the virtual machine
– BackupContainerName – name of the backup container
– BackupStorageAccountName – name of the backup storage account
– IncludeDataDisks – set if data disks need to backed up
All this said, you can now backup your VM with 4 lines of powershell code
This snippet takes a backup copy of all the disks for the VM named QNDTest1 in service QNDBackup for subscription ‘QND Subscription’ and saves them into the ‘backup’ container in storage account ‘qndvms’.
As you can read the function make it possible to have a specific storage account as a target for your backed up disks. This permits to save backup copies in a different storage account from the one that contains your running virtual machines. This is useful if you want this storage account not to be geo-replicated (it costs less), or if you just want to keep it separated from the storage account used for the running virtual machines. Using a different storage account has a drawback: longer virtual machine downtime. For example in my tests backing up a VM with an OS data disk set at 50 GB and a data disk sized 60 GB takes 70’ when using different storage accounts, while only 3’ when using the same storage account used to host virtual machines.
This is a starting point, a whole deployment backup can be automated, using this module, with System Center SMA taking into account Virtual Machines’s availability sets. A good idea for another post.
The powershell module can be downloaded from Technet Gallery.
This posting is provided “AS IS” with no warranties, and confers no rights.