Restore-AzRecoveryServicesBackupItem

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

Syntax

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

Description

The Restore-AzRecoveryServicesBackupItem 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-AzRecoveryServicesVaultContext cmdlet before you use the current cmdlet.

Examples

Example 1: Restore an item to a recovery point

PS C:\>$Container = Get-AzRecoveryServicesBackupContainer -ContainerType AzureVM -Status Registered -Name "V2VM"
PS C:\> $BackupItem = Get-AzRecoveryServicesBackupItem -ContainerType AzureVM -WorkloadType AzureVM 
PS C:\> $StartDate = (Get-Date).AddDays(-7) 
PS C:\> $EndDate = Get-Date
PS C:\> $RP = Get-AzRecoveryServicesBackupRecoveryPoint -Item $BackupItem -StartDate $StartDate.ToUniversalTime() -EndDate $EndDate.ToUniversalTime() 
PS C:\> $RestoreJob = Restore-AzRecoveryServicesBackupItem -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
Accept pipeline input:False
Accept wildcard characters:False
-DefaultProfile

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

Type:Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
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-AzRecoveryServicesBackupRecoveryPoint cmdlet.

Type:Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.RecoveryPointBase
Position:0
Default value:None
Accept pipeline input:True (ByValue)
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.RestoreFSResolveConflictOption
Accepted values:Overwrite, Skip
Position:Named
Default value:None
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
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:System.Nullable`1[Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.SourceFileType]
Accepted values:File, Directory
Position:Named
Default value:None
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
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
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
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
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
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
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
Accept pipeline input:False
Accept wildcard characters:False
-VaultId

ARM ID of the Recovery Services Vault.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-VaultLocation

Location of the Recovery Services Vault.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-WLRecoveryConfig

Recovery config

Type:Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.RecoveryConfigBase
Position:0
Default value:None
Accept pipeline input:True (ByValue)
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
Accept pipeline input:False
Accept wildcard characters:False

Inputs

String

Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.RecoveryPointBase

Outputs

Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.JobBase