Restores the data and configuration for a Backup item to the specified recovery point. The required parameters vary with the backup item type.
The same command is used to restore Azure Virtual machines, databases running within Azure Virtual machines and Azure file shares as well.
The Restore-AzRecoveryServicesBackupItem cmdlet restores the data and configuration for an Azure Backup item to a specified recovery point.
For Azure VM backup
You can backup Azure virtual machines and restore disks (both managed and un-managed) using this command. The restore operation does not restore the full virtual machine.
If this is a managed disk VM, a target Resource group should be specified where the restored disks are kept. When target resource group is specified, if the snapshots are present in the resource group that was specified in backup policy, the restore operation will be instant and the disks are created from local snapshots and kept in target-resource group. There is also an option to restore them as un-managed disks but this will leverage the data present in Azure recovery services vault and hence will be lot slower. The configuration of the VM and the deployment template which can be used to create VM out of the restored disks will be downloaded to the specified storage account.
If this is an un-managed disk VM, then the snapshots are present in disk's original storage account and/or in the recovery services vault. If user gives an option to use Original storage account to restore, then instant restore can be provided. Otherwise, data is fetched from Azure Recovery services vault and disks are created in specified storage account along with the configuration of the VM and the deployment template.
Important
By default, Azure VM backup backs up all disks. You can selectively backup relevant disks using the exclusionList or InclusionList parameters during Enable-Backup. The option to selectively restore disks is available only if one has selectively backed them up.
Please refer to different possible parameter sets and parameter text for more information.
Note
If -VaultId parameter is used then -VaultLocation parameter should be used as well.
For Azure File share backup
You can restore an entire file share or specific/multiple files/folders on the share. You can restore to the original location or to an alternate location.
For Azure Workloads
You can restore SQL DBs within Azure VMs
Examples
Example 1: Restore the disks of a backed up Managed disk Azure VM from a given recovery point
WorkloadName Operation Status StartTime EndTime
------------ --------- ------ --------- -------
V2VM Restore InProgress 26-Apr-16 1:14:01 PM 01-Jan-01 12:00:00 AM
The first command gets the Recovery Services vault and stores it in $vault variable.
The second command gets the Backup item of type AzureVM, of the name "V2VM", and stores it in the $BackupItem variable.
The third command gets the date from seven days earlier, and then stores it in the $StartDate variable.
The fourth command gets the current date, and then stores it in the $EndDate variable.
The fifth command gets a list of recovery points for the specific backup item filtered by $StartDate and $EndDate.
The last command restores all the disks to the target Resource group Target_RG, and then provides the VM configuration information and the deployment template in the storage account DestAccount in the DestRG resource group.
Example 2: Restore a Managed AzureVM from a given recovery point to original/alternate location
WorkloadName Operation Status StartTime EndTime
------------ --------- ------ --------- -------
V2VM Restore InProgress 26-Apr-16 1:14:01 PM 01-Jan-01 12:00:00 AM
The first command gets the Recovery Services vault and stores it in $vault variable.
The second command gets the Backup item of type AzureVM, of the name "V2VM", and stores it in the $BackupItem variable.
The third command gets the date from seven days earlier, and then stores it in the $StartDate variable.
The fourth command gets the current date, and then stores it in the $EndDate variable.
The fifth command gets a list of recovery points for the specific backup item filtered by $StartDate and $EndDate.
The sixth command triggers an Alternate Location Restore (ALR) to create a new VM in Target_RG resource group as per the inputs specified by parameters TargetVMName, TargetVNetName, TargetVNetResourceGroup, TargetSubnetName.
Alternately, if a user wants to perform an in-place restore to the originally backed up VM in the original location, it can be done with the last command. Please avoid using TargetResourceGroupName, RestoreAsUnmanagedDisks, TargetVMName, TargetVNetName, TargetVNetResourceGroup, TargetSubnetName parameters for performing Original Location Restore (OLR).
Example 3: Restore specified disks of a backed up Managed disk Azure VM from a given recovery point
WorkloadName Operation Status StartTime EndTime
------------ --------- ------ --------- -------
V2VM Restore InProgress 26-Apr-16 1:14:01 PM 01-Jan-01 12:00:00 AM
The first command gets the Recovery Services vault and stores it in $vault variable.
The second command gets the Backup item of type AzureVM, of the name "V2VM", and stores it in the $BackupItem variable.
The third command gets the date from seven days earlier, and then stores it in the $StartDate variable.
The fourth command gets the current date, and then stores it in the $EndDate variable.
The fifth command gets a list of recovery points for the specific backup item filtered by $StartDate and $EndDate.
The sixth command stores the list of disks to be restored in the restoreDiskLUN variable.
The last command restores the given disks, of the specified LUNs, to the target Resource group Target_RG, and then provides the VM configuration information and the deployment template in the storage account DestAccount in the DestRG resource group.
Example 4: Restore disks of a managed VM as unmanaged Disks
WorkloadName Operation Status StartTime EndTime
------------ --------- ------ --------- -------
V2VM Restore InProgress 26-Apr-16 1:14:01 PM 01-Jan-01 12:00:00 AM
The first command gets the RecoveryServices vault and stores it in $vault variable.
The second command gets the Backup item and then stores it in the $BackupItem variable.
The third command gets the date from seven days earlier, and then stores it in the $StartDate variable.
The fourth command gets the current date, and then stores it in the $EndDate variable.
The fifth command gets a list of recovery points for the specific backup item filtered by $StartDate and $EndDate.
The sixth command restores the disks as unmanaged disks.
Example 5: Restore an unmanaged VM as unmanaged Disks using original storage account
WorkloadName Operation Status StartTime EndTime
------------ --------- ------ --------- -------
V2VM Restore InProgress 26-Apr-16 1:14:01 PM 01-Jan-01 12:00:00 AM
The first command gets the RecoveryServices vault and stores it in $vault variable.
The second command gets the Backup item and then stores it in the $BackupItem variable.
The third command gets the date from seven days earlier, and then stores it in the $StartDate variable.
The fourth command gets the current date, and then stores it in the $EndDate variable.
The fifth command gets a list of recovery points for the specific backup item filtered by $StartDate and $EndDate.
The sixth command restores the disks as unmanaged disks to their original storage accounts
Example 6: Restore Multiple files of an AzureFileShare item
WorkloadName Operation Status StartTime EndTime
------------ --------- ------ --------- -------
fileshareitem Restore InProgress 26-Apr-16 1:14:01 PM 01-Jan-01 12:00:00 AM
The first command gets the Recovery Services vault and stores it in $vault variable.
The second command gets the Backup item named fileshareitem and then stores it in the $BackupItem variable.
The third command gets a list of recovery points for the specific backup item.
The fourth command specifies which files to restore and stores it in $files variable.
The last command restores the specified files to its original location.
Example 7: Restore a SQL DB within an Azure VM to another target VM for a distinct full recovery point
Here we filter the recovery points present in the VaultStandard tier and trigger a cross zonal restore for non-ZonePinned VM in a ZRS vault. For CZR we pass -TargetZoneNumber parameter. For Non-ZonedPinned VM, CZR is supported only for ZRS vaults. For ZonePinned VMs CZR is supported for ZRS vaults and cross region restore to secondary region for CRR enabled vaults.
Example 11: Cross zonal restore for non-ZonePinned VM to NoZone
In this example, we use RestoreToEdgeZone parameter to trigger a restore to new edge zone vm in alternate location. For Original location restore (OLR), restore will implicitly be an edge zone restore if the source VM is an edge zone VM.
Example 13: Restore a Managed AzureVM using DiskAccessOption
WorkloadName Operation Status StartTime EndTime
------------ --------- ------ --------- -------
V2VM Restore InProgress 26-Jul-24 1:14:01 PM 01-Jan-01 12:00:00 AM
In this example, we use DiskAccessOption parameter to trigger a restore to new VM with private access enabled for all disks. DiskAccessOption parameter can be used to specify the disk access option for target disks. The acceptable values for this parameter are: SameAsOnSourceDisks, EnablePrivateAccessForAllDisks, EnablePublicAccessForAllDisks. TargetDiskAccessId parameter is used to specify the disk access id for the target disks. This parameter is required when DiskAccessOption is set to EnablePrivateAccessForAllDisks.
Example 14: Restore disks of a Cross Subscription Backup protected VM to its original location
In this example, the backed up VM resides in a subscription different from the Recovery Services vault (Cross Subscription Backup). Original Location Recovery (OLR) is triggered by omitting the target location parameters (-TargetResourceGroupName, -TargetVMName, -TargetVNetName, -TargetVNetResourceGroup, -TargetSubnetName, -TargetSubscriptionId). The VM's subscription is derived automatically from the recovery point, and the target storage account is resolved in that subscription.
Parameters
-Confirm
Prompts you for confirmation before running the cmdlet.
Specify the Disk Encryption Set ID to use for OS disk encryption during restore of a Confidential VM. This is applicable only for Confidential VMs with managed disks. Please ensure that Disk Encryption Set has access to the Key vault.
Specifies the recovery point to which to restore the backup item.
To obtain an AzureRmRecoveryServicesBackupRecoveryPoint object, use the Get-AzRecoveryServicesBackupRecoveryPoint cmdlet.
In case the restored item also exists in the destination, use this to indicate whether to overwrite or not.
The acceptable values for this parameter are:
Parameter to authorize operations protected by cross tenant resource guard. Use command (Get-AzAccessToken -TenantId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx").Token to fetch authorization token for different tenant
Used for a particular item restore from a file share. The type of the item to be restored within the file share.
The acceptable values for this parameter are:
Specifies the name of the target Storage account in your subscription.
As a part of the restore process, this cmdlet stores the disks and the configuration information in this Storage account.
Specifies the name of the resource group that contains the target Storage account in your subscription.
As a part of the restore process, this cmdlet stores the disks and the configuration information in this Storage account.
The folder under which the file share has to be restored to within the TargetFileShareName. If the backed-up content is to be restored to a root folder, give the target folder values as an empty string.
Parameter to authorize operations protected by cross tenant resource guard. Use command (Get-AzAccessToken -TenantId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx").Token to fetch authorization token for different tenant
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters.
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.