ערוך

שתף באמצעות


Create virtual machine restore points using Azure CLI

You can protect your data and guard against extended downtime by creating VM restore points at regular intervals. You can create VM restore points, and exclude disks while creating the restore point, using Azure CLI. Azure CLI is used to create and manage Azure resources using command line or scripts. Alternatively, you can create VM restore points using the Azure portal or using PowerShell.

The az restore-point module is used to create and manage restore points from the command line or in scripts.

In this tutorial, you learn how to:

Prerequisites

Step 1: Create a VM restore point collection

Use the az restore-point collection create command to create a VM restore point collection, as shown below:

az restore-point collection create --location "norwayeast" --source-id "/subscriptions/{subscription-id}/resourceGroups/ExampleRg/providers/Microsoft.Compute/virtualMachines/ExampleVM" --tags myTag1="tagValue1" --resource-group "ExampleRg" --collection-name "ExampleRpc"

Step 2: Create a VM restore point

Create a VM restore point with the az restore-point create command as follows:

az restore-point create --resource-group "ExampleRg" --collection-name "ExampleRpc" --name "ExampleRp"

To create a crash consistent restore point set the optional parameter "consistency-mode" to "CrashConsistent". This feature is currently in preview.

Exclude disks when creating a restore point

Exclude the disks that you do not want to be a part of the restore point with the --exclude-disks parameter, as follows:

az restore-point create --exclude-disks "/subscriptions/{subscription-id}/resourceGroups/ExampleRg/providers/Microsoft.Compute/disks/ExampleDisk1" --resource-group "ExampleRg" --collection-name "ExampleRpc" --name "ExampleRp"

Step 3: Track the status of the VM restore point creation

Use the az restore-point show command to track the progress of the VM restore point creation.

az restore-point show --resource-group "ExampleRg" --collection-name "ExampleRpc" --name "ExampleRp"

Restore a VM from VM restore point

To restore a VM from a VM restore point, first restore individual disks from each disk restore point. You can also use the ARM template to restore a full VM along with all the disks.

# Create Disks from disk restore points 
$osDiskRestorePoint = az restore-point show --resource-group "ExampleRg" --collection-name "ExampleRpc" --name "ExampleRp" --query "sourceMetadata.storageProfile.dataDisks[0].diskRestorePoint.id"
$dataDisk1RestorePoint = az restore-point show --resource-group "ExampleRg" --collection-name "ExampleRpcTarget" --name "ExampleRpTarget" –query "sourceMetadata.storageProfile.dataDisks[0].diskRestorePoint.id"
$dataDisk2RestorePoint = az restore-point show --resource-group "ExampleRg" --collection-name "ExampleRpcTarget" --name "ExampleRpTarget" –query "sourceMetadata.storageProfile.dataDisks[0].diskRestorePoint.id"
 
az disk create --resource-group “ExampleRg” --name “ExampleOSDisk” --sku Premium_LRS --size-gb 128 --source $osDiskRestorePoint

az disk create --resource-group “ExampleRg” --name “ExampleDataDisk1” --sku Premium_LRS --size-gb 128 --source $dataDisk1RestorePoint

az disk create --resource-group “ExampleRg” --name “ExampleDataDisk1” --sku Premium_LRS --size-gb 128 --source $dataDisk2RestorePoint

Once you have created the disks, create a new VM and attach these restored disks to the newly created VM.

Next steps

Learn more about Backup and restore options for virtual machines in Azure.