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.
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.
- Log into the ARM portal and navigate to your Recovery Services page.
- Click the Backup button.
- Select Azure and Virtual machine and click OK.
- Select a backup policy. You may want to create your own beforehand.
- Select the Server to back up and click OK.
- Click Enable Backup and you are done with creating the backup Job for the server.
Run the On-Demand Backup
- Log into ARM portal and navigate to the Recovery Services page.
- Click on Azure Virtual Machines under Backup Items.
- Select the server to backup.
- Click Backup Now then click Yes.
- You can track the backup progress in the Jobs item in the Recovery Services Vault blade. I found the backup to be relatively quick.
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.
- Log into Azure RM portal and navigate to the Recovery Services Vault.
- Click on Jobs and then Backup Jobs.
- Select the Job in the list. You will see the status.
- 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.
- 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.
- 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).
AzCopy /Source:https://rsgroup.blob.core.windows.net/vhdpath /Dest:z: /SourceKey:abc /Pattern:"vhdname.vhd"
- Open the mapped drive in Windows explorer and change the name of the VHD to something identifiable
- Copy the file back to the VHDS Blob Container with AzCopy (1+hr for 127 GB VHD) using the
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.
- 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.
- 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.
Create a new VM with a static IP and attach the recovered VHD
- Download this script: RestoreVMfromRecoveredVHD.ps1 file and right-click to Edit.
- Update the variables for the Server and save.
- Right-click the file and Run with Powershell.
- 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.
- 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).