Restore-AzureRmRecoveryServicesBackupItem

Restores the data and configuration for a Backup item to a recovery point.

Warning

The AzureRM PowerShell module has been officially deprecated as of February 29, 2024. Users are advised to migrate from AzureRM to the Az PowerShell module to ensure continued support and updates.

Although the AzureRM module may still function, it's no longer maintained or supported, placing any continued use at the user's discretion and risk. Please refer to our migration resources for guidance on transitioning to the Az module.

Syntax

Restore-AzureRmRecoveryServicesBackupItem
       [-VaultLocation <String>]
       [-RecoveryPoint] <RecoveryPointBase>
       [-StorageAccountName] <String>
       [-StorageAccountResourceGroupName] <String>
       [[-TargetResourceGroupName] <String>]
       [-UseOriginalStorageAccount]
       [-VaultId <String>]
       [-DefaultProfile <IAzureContextContainer>]
       [-WhatIf]
       [-Confirm]
       [<CommonParameters>]
Restore-AzureRmRecoveryServicesBackupItem
       [-VaultLocation <String>]
       [-RecoveryPoint] <RecoveryPointBase>
       [-StorageAccountName] <String>
       [-StorageAccountResourceGroupName] <String>
       -ResolveConflict <RestoreFSResolveConfictOption>
       [-SourceFilePath <String>]
       [-SourceFileType <SourceFileType>]
       [-TargetStorageAccountName <String>]
       [-TargetFileShareName <String>]
       [-TargetFolder <String>]
       [-VaultId <String>]
       [-DefaultProfile <IAzureContextContainer>]
       [-WhatIf]
       [-Confirm]
       [<CommonParameters>]

Description

The Restore-AzureRmRecoveryServicesBackupItem cmdlet restores the data and configuration for an Azure Backup item to a specified recovery point. This cmdlet starts the restore from the Recovery Services vault to customer's storage account. The restore operation does not restore the full virtual machine. It restores the disk data and configuration information. After the restore operation is finished, you must create the virtual machine and start it. Set the vault context by using the Set-AzureRmRecoveryServicesVaultContext cmdlet before you use the current cmdlet.

Examples

Example 1: Restore an item to a recovery point

PS C:\>$Container = Get-AzureRmRecoveryServicesBackupContainer -ContainerType AzureVM -Status Registered -Name "V2VM"
PS C:\> $BackupItem = Get-AzureRmRecoveryServicesBackupItem -ContainerType AzureVM -WorkloadType AzureVM 
PS C:\> $StartDate = (Get-Date).AddDays(-7) 
PS C:\> $EndDate = Get-Date
PS C:\> $RP = Get-AzureRmRecoveryServicesBackupRecoveryPoint -Item $BackupItem -StartDate $StartDate.ToUniversalTime() -EndDate $EndDate.ToUniversalTime() 
PS C:\> $RestoreJob = Restore-AzureRmRecoveryServicesBackupItem -RecoveryPoint $RP[0] -StorageAccountName "DestAccount" -StorageAccountResourceGroupName "DestRG"
    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 Backup container of type AzureVM, and then stores it in the $Container variable. The second command gets the Backup item named V2VM from $Container, 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 date range specified is the last 7 days. The last command restores the disks to the target storage account DestAccount in the DestRG resource group.

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure.

Type:IAzureContextContainer
Aliases:AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-RecoveryPoint

Specifies the recovery point to which to restore the virtual machine. To obtain an AzureRmRecoveryServicesBackupRecoveryPoint object, use the Get-AzureRmRecoveryServicesBackupRecoveryPoint cmdlet.

Type:RecoveryPointBase
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ResolveConflict

In case the restored item also exists in the destination, use this to indicate whether to overwrite or not.

Type:Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.RestoreFSResolveConfictOption
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-SourceFilePath

Used for a particular item restore from a file share. The path of the item to be restored within the file share.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-SourceFileType

Used for a particular item restore from a file share. The path of the item to be restored within the file share.

Type:SourceFileType
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-StorageAccountName

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.

Type:String
Position:1
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-StorageAccountResourceGroupName

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.

Type:String
Position:2
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-TargetFileShareName

The File Share to which the file share has to be restored to.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-TargetFolder

The folder under which the file share has to be restored to within the targetFileShareName.Leave the variable empty to restore under root folder.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-TargetResourceGroupName

The resource group to which the managed disks are restored. Applicable to backup of VM with managed disks

Type:String
Position:3
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-TargetStorageAccountName

The storage account to which the file share has to be restored to.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-UseOriginalStorageAccount

Use this switch if the disks from the recovery point are to be restored to their original storage accounts.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-VaultId

ARM ID of the Recovery Services Vault.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-VaultLocation

Location of the Recovery Services Vault.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

String

Parameters: VaultId (ByValue), VaultLocation (ByValue)

RecoveryPointBase

Parameters: RecoveryPoint (ByValue)

Outputs

JobBase