Backup and Restore of Azure Virtual Machines

Microsoft recently announced a new capability in Azure that provides the ability to create snapshots of running Virtual Machines (OS and data disks).   It is implemented as a specialized image that can be then provisioned using the New-AzureQuickVM cmdlet.     The functionality is not currently available through the Azure Management Portal, but can be done via Azure PowerShell cmdlets available with the Azure SDK.

I will walk through an example of “backing up”  a virtual machine using the Save-AzureVMImage cmdlet, and then “restoring” from that specialized image.  If you are new to managing Azure with PowerShell, refer to How to install and configure Azure PowerShell.

The virtual machine to be backed up is C9test:

PS C:\> get-azurevm | where {$_.Name -eq "c9test"}
ServiceName                Name                       Status
-----------                ----                       ------
C9Test                     C9Test                     ReadyRole                 

C9Test has the following disks (1 OS disk and 1 data disk) in blob storage:

  b1

1. Execute Save-AzureVMImage to create the specialized image (Backup)

PS C:\> Save-AzureVMImage -ServiceName "c9test" -Name "C9test" -ImageName "c9test-backup" -OSState Specialized

OperationDescription             OperationId                                 OperationStatus 
--------------------             -----------                                 --------------- 

Save-AzureVMImage                dbf853a7-9a3b-9f46-97a8-25700dfc8cf9        Succeeded

The disks created are named as follows:

<vm name>-os-YYYY-MM-DD.vhd    (for the OS disk)

<vm name>-datadisk-<#>-YYYY-MM-DD.vhd   (for the data disks)

Here are the disks created in this example:

 b2

2. Delete the C9test virtual machine and cloud service  (so we can demonstrate the restore from image)

Remove virtual machine:

PS C:\> Remove-AzureVM -Name "c9test" -ServiceName "c9test" -DeleteVHD
OperationDescription         OperationId                                OperationStatus                           
--------------------         -----------                                ---------------
Remove-AzureVM               26b610c1-e49c-9182-a54c-1ab8ed4c4022       Succeeded

Disks have been removed and only disks from the backup exist:

b3

Remove cloud service:

PS C:\> remove-azureservice -ServiceName "C9test" -Force
WARNING: 10:02:41 PM - Removing cloud service C9test...

3. Create a Virtual Machine from the specialized image using New-AzureQuickVM (Restore)

PS C:\> New-AzureQuickVM -ImageName "C9Test-backup" -Windows -ServiceName "C9Test" -Location "East US"

OperationDescription                       OperationId                                OperationStatus
--------------------                       -----------                                ---------------
New-AzureQuickVM                           fd42d11b-f9c0-95d8-92e2-c666d7ef8de3       Succeeded
New-AzureQuickVM                           6261cc5a-b3d6-9c72-9808-3013fbad8274       Succeeded 

PS C:\> get-azurevm | where {$_.Name -eq "c9test"}

ServiceName                     Name                               Status
-----------                     ----                               ------
C9Test                          C9Test                             ReadyRole

The VM creation has created new disks in blob storage:

 b4

 

To remove saved Images, you can use the Remove-AzureVMImage cmdlet

PS C:\> remove-azurevmimage -ImageName "c9test-backup" -DeleteVHD
OperationDescription               OperationId                                 OperationStatus                           
--------------------               -----------                                 ---------------
Remove-AzureVMImage                f11c14e2-dac7-993b-9811-5c944f9e8428        Succeeded

Hopefully this example around saving specialized images will help you implement a backup strategy for your Microsoft Azure virtual machines.   Cloud9 has additional tools and techniques for managing virtual machines and storage.   Contact us at info@cloud9infosystems.com or 1-855 2CLOUD9 to for more information.

Ken Channon

kenc@cloud9infosystems.com

 

 

 

 

 

Advertisements

About Cloud 9 Infosystems

Cloud 9 Infosystems is an Azure Circle Partner specializing in building, migrating and managing applications in Cloud. We were awarded the Most Valuable Partner Award by Microsoft for our Cloud services. We are also part of Azure insider club and P-seller program at Microsoft.
This entry was posted in Cloud Computing, Windows Azure. Bookmark the permalink.

One Response to Backup and Restore of Azure Virtual Machines

  1. Hi! Is there a cmdlet to retrieve all of the the image names in your blob storage?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s