<img src="//bat.bing.com/action/0?ti=5794969&amp;Ver=2" height="0" width="0" style="display:none; visibility: hidden;">

How To: Azure Resource Manager VM Level Backup & Restore Without Snapshots

[fa icon="long-arrow-left"] Back to all posts

[fa icon="pencil'] Posted by Phillip Martin [fa icon="calendar"] August 25, 2016

One basic task I found very underwhelming in the Microsoft Azure Resource Manager (ARM) portal was the backup. If you're thinking about taking a snapshot of a server as a precaution before you make any updates—sorry—snapshots don’t exist. You'll have to replace snapshots with backup and restore. I’ll break this down into the three parts: Backup, Recover, and Restore.

Backup

Setup the Backup Job

The backup is actually very easy and fast. First, you need to create a Recover Services Vault from the portal. One downside is that you can’t backup a server without adding it to the backup jobs. However, after you have added it, you can run on demand backups at any point.

  1. Log into the ARM portal and navigate to your Recovery Services page.
  2. Click the Backup button.

ARM-Backup-Restore-Step-1.jpg

  1. Select Azure and Virtual machine and click OK.

ARM-Backup-Restore-Step-2.jpg

  1. Select a backup policy. You may want to create your own beforehand.

ARM-Backup-Restore-Step-3.jpg

  1. Select the Server to back up and click OK.

ARM-Backup-Restore-Step-4.jpg

  1. Click Enable Backup and you are done with creating the backup Job for the server.

Run the On-Demand Backup

  1. Log into ARM portal and navigate to the Recovery Services page.
  2. Click on Azure Virtual Machines under Backup Items.

ARM-Backup-Restore-Step-5.jpg

  1. Select the server to backup.
  2. Click Backup Now then click Yes.

ARM-Backup-Restore-Step-6.jpg

  1. You can track the backup progress in the Jobs item in the Recovery Services Vault blade. I found the backup to be relatively quick.

Recover

There are really two options at this point.

The first option is to restore from the backup in the portal to a new server. This is by far the fastest option, so for critical issues this may be what you have to do. The downsides to this option are that you can’t set a static IP, the restored VHD is assigned a random name and the VHD is saved in the root of the storage account versus the VHD container. If you want to restore the server from backup with the same server name, you must first DELETE THE EXISTING SERVER and then restore to a new VM with the same name (this is true regardless of the option you choose).

Option two is to recover the VHD to a share where you can change the VHD name (because you CANNOT change a VHD name once it is created) and then move it to the VHD folder. I like option two because it is cleaner and more organized. The downside though is that it is a lot slower.

Option two is what I will cover here. For this, you need to first create an Azure File Share because you do not want to transfer this much data in and out of azure.

  1. Log into Azure RM portal and navigate to the Recovery Services Vault.
  2. Click on Jobs and then Backup Jobs.

ARM-Backup-Restore-Step-7.jpg

  1. Select the Job in the list. You will see the status.
  2. View the properties of the Job to see what the VHD name and location are once the Job is complete. Note the VHD name and Location.

ARM-Backup-Restore-Step-8.jpg

  1. Map the Azure File Share in Windows explorer. Here is a resource on azure File Share. I usually do this from a server already in Azure.
  2. UseAZcopy to copy the VHD to the mapped drive. You got the source and pattern from the recovered VHD info earlier. This can take a while (1+ hours for 127GB).

Example: AzCopy /Source:https://rsgroup.blob.core.windows.net/vhdpath /Dest:z: /SourceKey:abc /Pattern:"vhdname.vhd"

  1. Open the mapped drive in Windows explorer and change the name of the VHD to something identifiable
  2. Copy the file back to the VHDS Blob Container with AzCopy (1+hr for 127 GB VHD) using the /blobType:Page switch.

Example: AzCopy /Source:z: /Dest:https://rsgroup.blob.core.windows.net/vhds /DestKey:abc /Pattern:"vhdname.vhd" /blobType:Page

Note: You must use the /blobType:Page switch or the VM creation will fail.
Note:
You also must copy from the mapped drive or the /blobType:Page switch is invalid.

  1. Note the name and static IP of the server you want to restore. If there is a public IP assigned, you will have to re-add this later or update my script.
  2. Delete the existing VM, Disk and NIC. I know, this scared me too, but you have to if you want to restore to a VM with the same name.

Recover

Create a new VM with a static IP and attach the recovered VHD

  1. Download this script: RestoreVMfromRecoveredVHD.ps1 file and right-click to Edit.
  2. Update the variables for the Server and save.
  3. Right-click the file and Run with Powershell.
  4. Sign into your Azure Account that has permission. The script will launch the web sign in form and the script will run. Then close the Powershell window when done.
  5. You should see the VM getting created in the Portal and it will start up.
    Note: You may need to rejoin the server to the domain if the AD machine account password has changed.

There you go!

Related Post: Bug Fix: View Templates Folder in Azure Resource Manager Premium Storage


Lewan is a Microsoft Silver Partner, and a Microsoft Certified Solutions Expert (MCSE) and Microsoft Certified Professional (MCP).

Topics: Data Backup & Recovery, Microsoft, How To Guide, Microsoft Windows, PowerShell, Microsoft Azure

Phillip Martin
Written by Phillip Martin

Phillip is a Lead Senior Systems Engineer at Lewan.

  • View & Submit Comments

[fa icon="envelope"] Subscribe to Email Updates



[fa icon="comments-o"] Follow us

Get even more great content, photos, event info and industry news.



[fa icon="calendar"] Recent Posts