As Azure provides a perfect Azure Backup Solution for Virtual Machines. There is another alternate way where you can create your own customized Backup Solution for Virtual machines using Blob Snapshots.
Azure Storage provides the capability to take snapshots of blobs.
You might me wondering what is a Snapshots ?
In Hyper-V Environment the configuration, memory, and supporting process information is saved and a differencing disk is created to store future disk changes. When you delete a VM, all the snapshots are deleted. However, the virtual hard disk (VHD) is not deleted, which means all content stored in the differencing disks associated with the snapshots must be merged with the original VHD, as the following diagram shows.
In Azure its similar where Azure capture the blob state at that point in time. Lets dig down the scenario of how we can maintain backups of virtual machine disks using snapshots.
What is a Blob Snapshot?
A blob snapshot is a read-only version of a blob that is captured at a point in time. Once a snapshot has been created, it can be read, copied, or deleted, but not modified.
Note: Snapshots can be copied to another storage account as a blob to keep backups of the base blob. You can also copy a snapshot over its base blob, which is like restoring the blob to an earlier version. When a snapshot is copied from one storage account to another, it will occupy the same space as the base page blob. Therefore, copying whole snapshots from one storage account to another will be slow and will also consume lot of space in the target storage account
Steps for Implementing a full snapshot copy:
- First, take a snapshot of the base blob using the Snapshot Blob operation.
- Then, copy the snapshot to a target storage account using Copy Blob.
- Repeat this process to maintain backup copies of your base blob.
For execution, please find the Automated Powershell Script which Create Snapshot for unmanaged Virtual Machines in a resource group: Link
The above script is for creating Blob Snapshots for all Azure IaaS VMs(includes root volume and Data volumes) for Azure Resource Manager VM(unmanaged disks). This is intended to run only for Virtual Machines with TagName as "Environment" and TagValue as "Production". You can also automate the process of Blob Snapshot by publishing the script in Azure Automation as well with few changes.
See the corresponding article for details and instructions:https://docs.microsoft.com/en-us/azure/storage/storage-blob-snapshots
NOTE: It is suggested that you download the script file from this page instead of copying and pasting the script code below, in order to avoid any formatting issues that may affect script execution.
Thanks for reading. Following to this blog we will have a detailed blog explaining how to restore an unmanaged VM in Azure using Powershell Scripts.
Happy Reading :)