Technical Thursday – Restore VM from RSV – unmanaged disk

As I promised last week I provide some materials for unmanaged disk based VM restore from Recovery Services vault. Last week I posted the concept for restore and now I show the most important steps on technical level.

 

Some useful information before you start the restore:

Required naming convention

OS disk and Data disks related vhds must be in the following format:

  • OS disk:
    • [vmname]-osdisk.vhd
  • Data disk:
    • [vmname]-datadisk-[diskid].vhd (where the diskid represents the value of lun)
    • (example for 1st data disk: myvm-datadisk-0.vhd)

Prerequisites

  • Azure-Cli 2.x
  • Python 2.7

 

And now let’s see the steps one-by-one:

1. Stopped (deallocated) the target VM

This step is executable from PowerShell, Azure-Cli and Portal as well.

# Stop (deallocated) vm from Azure-Cli 2.x
az vm deallocate --name <vm name> --resource-group <resource group name> --verbose

Be sure the VM is in Stopped (deallocated) status!

2.Delete necessary objects

In this step we have to delete target VM object (ONLY the virtual machine object) and vhd files which belong to target VM.

  1. Login your linux computer
  2. Download files from git
  3. Navigate the UnmanagedDisk directory
  4. Run this command to delete VM object and the corrupt VHDs
bash 01_deleteVMandVHDs.sh

3. Restore VM’s VHDs from backup vault

Choose the right restore point from Recovery Services vaults which belongs to target VM and Restore OSDisk and DataDisks to your storage account.

https://docs.microsoft.com/en-us/azure/backup/backup-azure-arm-restore-vms

4. Move restored vhd files to original location

  1. Login your linux computer
  2. Download files from git
  3. Navigate the UnmanagedDisk directory
  4. Run this command to copy restored VHD files to the original location
bash 02_copyRestoredVHDs.sh

 

5. Re-create target VM with your ARM Template

In this step you merely redeploy your vm from that ARM template you had created for original vm creation.

 

I hope it helps to solve your restore VM problem. 🙂

Next week I will show you the managed disk based VM restore related steps…

 

If you need some help regarding ARM Template for restore or other scenarios do not hesitate to contact me.

Leave a comment