From 31e9b72a6aeb9e50ada2627089fd0f0df1ff369b Mon Sep 17 00:00:00 2001 From: Himanshu Agarwal Date: Wed, 18 Nov 2020 23:30:52 +0530 Subject: [PATCH] [RecoveryServices.Backup] Making help text changes to Restore-AzRecoveryServicesBackupItem cmdlet (#13523) * Making help text changes to Restore-AzRecoveryServicesBackupItem cmdlet * resolving Analyze tool error --- ...estoreAzureRMRecoveryServicesBackupItem.cs | 60 +++--- .../RecoveryServices/ChangeLog.md | 1 + .../Restore-AzRecoveryServicesBackupItem.md | 172 +++++++++++------- ...zRecoveryServicesBackupProtectionPolicy.md | 12 +- 4 files changed, 144 insertions(+), 101 deletions(-) diff --git a/src/RecoveryServices/RecoveryServices.Backup/Cmdlets/Restore/RestoreAzureRMRecoveryServicesBackupItem.cs b/src/RecoveryServices/RecoveryServices.Backup/Cmdlets/Restore/RestoreAzureRMRecoveryServicesBackupItem.cs index ab6e0044b64a..1de40da41636 100644 --- a/src/RecoveryServices/RecoveryServices.Backup/Cmdlets/Restore/RestoreAzureRMRecoveryServicesBackupItem.cs +++ b/src/RecoveryServices/RecoveryServices.Backup/Cmdlets/Restore/RestoreAzureRMRecoveryServicesBackupItem.cs @@ -31,10 +31,10 @@ namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets public class RestoreAzureRmRecoveryServicesBackupItem : RSBackupVaultCmdletBase { internal const string AzureVMParameterSet = "AzureVMParameterSet"; - internal const string AzureVMTargetRGParameterSet = "AzureVMTargetRGParameterSet"; - internal const string AzureVMRestoreAsUnmanaged = "AzureVMRestoreAsUnmanaged"; - internal const string AzureVMUseOSAParameterSet = "AzureVMUseOSAParameterSet"; - internal const string AzureFileParameterSet = "AzureFileParameterSet"; + internal const string AzureVMManagedDiskParameterSet = "AzureVMManagedDiskParameterSet"; + internal const string AzureVMRestoreManagedAsUnmanaged = "AzureVMRestoreManagedAsUnmanaged"; + internal const string AzureVMUnManagedDiskParameterSet = "AzureVMUnManagedDiskParameterSet"; + internal const string AzureFileShareParameterSet = "AzureFileShareParameterSet"; internal const string AzureWorkloadParameterSet = "AzureWorkloadParameterSet"; /// @@ -52,13 +52,13 @@ public class RestoreAzureRmRecoveryServicesBackupItem : RSBackupVaultCmdletBase [Parameter(Mandatory = true, ValueFromPipeline = true, Position = 0, ParameterSetName = AzureVMParameterSet, HelpMessage = ParamHelpMsgs.RestoreDisk.RecoveryPoint)] [Parameter(Mandatory = true, ValueFromPipeline = true, Position = 0, - ParameterSetName = AzureFileParameterSet, HelpMessage = ParamHelpMsgs.RestoreDisk.RecoveryPoint)] + ParameterSetName = AzureFileShareParameterSet, HelpMessage = ParamHelpMsgs.RestoreDisk.RecoveryPoint)] [Parameter(Mandatory = true, ValueFromPipeline = true, Position = 0, - ParameterSetName = AzureVMRestoreAsUnmanaged, HelpMessage = ParamHelpMsgs.RestoreDisk.RecoveryPoint)] + ParameterSetName = AzureVMRestoreManagedAsUnmanaged, HelpMessage = ParamHelpMsgs.RestoreDisk.RecoveryPoint)] [Parameter(Mandatory = true, ValueFromPipeline = true, Position = 0, - ParameterSetName = AzureVMTargetRGParameterSet, HelpMessage = ParamHelpMsgs.RestoreDisk.RecoveryPoint)] + ParameterSetName = AzureVMManagedDiskParameterSet, HelpMessage = ParamHelpMsgs.RestoreDisk.RecoveryPoint)] [Parameter(Mandatory = true, ValueFromPipeline = true, Position = 0, - ParameterSetName = AzureVMUseOSAParameterSet, HelpMessage = ParamHelpMsgs.RestoreDisk.RecoveryPoint)] + ParameterSetName = AzureVMUnManagedDiskParameterSet, HelpMessage = ParamHelpMsgs.RestoreDisk.RecoveryPoint)] [ValidateNotNullOrEmpty] public RecoveryPointBase RecoveryPoint { get; set; } @@ -75,11 +75,11 @@ public class RestoreAzureRmRecoveryServicesBackupItem : RSBackupVaultCmdletBase /// [Parameter(Mandatory = true, Position = 1, ParameterSetName = AzureVMParameterSet, HelpMessage = ParamHelpMsgs.RestoreDisk.StorageAccountName)] - [Parameter(Mandatory = true, Position = 1, ParameterSetName = AzureVMTargetRGParameterSet, + [Parameter(Mandatory = true, Position = 1, ParameterSetName = AzureVMManagedDiskParameterSet, HelpMessage = ParamHelpMsgs.RestoreDisk.StorageAccountName)] - [Parameter(Mandatory = true, Position = 1, ParameterSetName = AzureVMUseOSAParameterSet, + [Parameter(Mandatory = true, Position = 1, ParameterSetName = AzureVMUnManagedDiskParameterSet, HelpMessage = ParamHelpMsgs.RestoreDisk.StorageAccountName)] - [Parameter(Mandatory = true, Position = 1, ParameterSetName = AzureVMRestoreAsUnmanaged, + [Parameter(Mandatory = true, Position = 1, ParameterSetName = AzureVMRestoreManagedAsUnmanaged, HelpMessage = ParamHelpMsgs.RestoreDisk.StorageAccountName)] [ValidateNotNullOrEmpty] public string StorageAccountName { get; set; } @@ -89,11 +89,11 @@ public class RestoreAzureRmRecoveryServicesBackupItem : RSBackupVaultCmdletBase /// [Parameter(Mandatory = true, Position = 2, ParameterSetName = AzureVMParameterSet, HelpMessage = ParamHelpMsgs.RestoreDisk.StorageAccountResourceGroupName)] - [Parameter(Mandatory = true, Position = 2, ParameterSetName = AzureVMUseOSAParameterSet, + [Parameter(Mandatory = true, Position = 2, ParameterSetName = AzureVMUnManagedDiskParameterSet, HelpMessage = ParamHelpMsgs.RestoreDisk.StorageAccountResourceGroupName)] - [Parameter(Mandatory = true, Position = 2, ParameterSetName = AzureVMTargetRGParameterSet, + [Parameter(Mandatory = true, Position = 2, ParameterSetName = AzureVMManagedDiskParameterSet, HelpMessage = ParamHelpMsgs.RestoreDisk.StorageAccountResourceGroupName)] - [Parameter(Mandatory = true, Position = 2, ParameterSetName = AzureVMRestoreAsUnmanaged, + [Parameter(Mandatory = true, Position = 2, ParameterSetName = AzureVMRestoreManagedAsUnmanaged, HelpMessage = ParamHelpMsgs.RestoreDisk.StorageAccountResourceGroupName)] [ValidateNotNullOrEmpty] public string StorageAccountResourceGroupName { get; set; } @@ -101,7 +101,7 @@ public class RestoreAzureRmRecoveryServicesBackupItem : RSBackupVaultCmdletBase /// /// The resource group to which the managed disks are restored. This parameter is mandatory for backup of VM with managed disks. /// - [Parameter(Mandatory = true, Position = 3, ParameterSetName = AzureVMTargetRGParameterSet, + [Parameter(Mandatory = true, Position = 3, ParameterSetName = AzureVMManagedDiskParameterSet, HelpMessage = ParamHelpMsgs.RestoreVM.TargetResourceGroupName)] [ValidateNotNullOrEmpty] public string TargetResourceGroupName { get; set; } @@ -109,7 +109,7 @@ public class RestoreAzureRmRecoveryServicesBackupItem : RSBackupVaultCmdletBase /// /// Resolve conflict option /// - [Parameter(Mandatory = true, ParameterSetName = AzureFileParameterSet, + [Parameter(Mandatory = true, ParameterSetName = AzureFileShareParameterSet, HelpMessage = ParamHelpMsgs.RestoreFS.ResolveConflict)] [ValidateNotNullOrEmpty] public RestoreFSResolveConflictOption ResolveConflict { get; set; } @@ -117,7 +117,7 @@ public class RestoreAzureRmRecoveryServicesBackupItem : RSBackupVaultCmdletBase /// /// Source File Path of the file to be recovered /// - [Parameter(Mandatory = false, ParameterSetName = AzureFileParameterSet, + [Parameter(Mandatory = false, ParameterSetName = AzureFileShareParameterSet, HelpMessage = ParamHelpMsgs.RestoreFS.SourceFilePath)] [ValidateNotNullOrEmpty] public string SourceFilePath { get; set; } @@ -125,7 +125,7 @@ public class RestoreAzureRmRecoveryServicesBackupItem : RSBackupVaultCmdletBase /// /// Source File Type of the file to be recovered /// - [Parameter(Mandatory = false, ParameterSetName = AzureFileParameterSet, + [Parameter(Mandatory = false, ParameterSetName = AzureFileShareParameterSet, HelpMessage = ParamHelpMsgs.RestoreFS.SourceFilePath)] [ValidateNotNullOrEmpty] public SourceFileType? SourceFileType { get; set; } @@ -133,7 +133,7 @@ public class RestoreAzureRmRecoveryServicesBackupItem : RSBackupVaultCmdletBase /// /// Target storage account name where the disks need to be recovered /// - [Parameter(Mandatory = false, ParameterSetName = AzureFileParameterSet, + [Parameter(Mandatory = false, ParameterSetName = AzureFileShareParameterSet, HelpMessage = ParamHelpMsgs.RestoreFS.TargetStorageAccountName)] [ValidateNotNullOrEmpty] public string TargetStorageAccountName { get; set; } @@ -141,7 +141,7 @@ public class RestoreAzureRmRecoveryServicesBackupItem : RSBackupVaultCmdletBase /// /// The target file share name to which the files are restored. /// - [Parameter(Mandatory = false, ParameterSetName = AzureFileParameterSet, + [Parameter(Mandatory = false, ParameterSetName = AzureFileShareParameterSet, HelpMessage = ParamHelpMsgs.RestoreFS.TargetFileShareName)] [ValidateNotNullOrEmpty] public string TargetFileShareName { get; set; } @@ -149,7 +149,7 @@ public class RestoreAzureRmRecoveryServicesBackupItem : RSBackupVaultCmdletBase /// /// The target folder name to which the files are restored. /// - [Parameter(Mandatory = false, ParameterSetName = AzureFileParameterSet, + [Parameter(Mandatory = false, ParameterSetName = AzureFileShareParameterSet, HelpMessage = ParamHelpMsgs.RestoreFS.TargetFolder)] [ValidateNotNullOrEmpty] public string TargetFolder { get; set; } @@ -157,14 +157,14 @@ public class RestoreAzureRmRecoveryServicesBackupItem : RSBackupVaultCmdletBase /// /// Array of source file paths to be recovered /// - [Parameter(Mandatory = false, ParameterSetName = AzureFileParameterSet, + [Parameter(Mandatory = false, ParameterSetName = AzureFileShareParameterSet, HelpMessage = ParamHelpMsgs.RestoreFS.MultipleSourceFilePath)] public string[] MultipleSourceFilePath { get; set; } /// /// Use this switch if the disks from the recovery point are to be restored to their original storage accounts /// - [Parameter(Mandatory = true, ParameterSetName = AzureVMUseOSAParameterSet, + [Parameter(Mandatory = true, ParameterSetName = AzureVMUnManagedDiskParameterSet, HelpMessage = ParamHelpMsgs.RestoreVM.OsaOption)] public SwitchParameter UseOriginalStorageAccount { get; set; } @@ -173,11 +173,11 @@ public class RestoreAzureRmRecoveryServicesBackupItem : RSBackupVaultCmdletBase /// [Parameter(Mandatory = false, ParameterSetName = AzureVMParameterSet, HelpMessage = ParamHelpMsgs.RestoreVM.RestoreOnlyOSDisk)] - [Parameter(Mandatory = false, ParameterSetName = AzureVMTargetRGParameterSet, + [Parameter(Mandatory = false, ParameterSetName = AzureVMManagedDiskParameterSet, HelpMessage = ParamHelpMsgs.RestoreVM.RestoreOnlyOSDisk)] - [Parameter(Mandatory = false, ParameterSetName = AzureVMRestoreAsUnmanaged, + [Parameter(Mandatory = false, ParameterSetName = AzureVMRestoreManagedAsUnmanaged, HelpMessage = ParamHelpMsgs.RestoreVM.RestoreOnlyOSDisk)] - [Parameter(Mandatory = false, ParameterSetName = AzureVMUseOSAParameterSet, + [Parameter(Mandatory = false, ParameterSetName = AzureVMUnManagedDiskParameterSet, HelpMessage = ParamHelpMsgs.RestoreVM.RestoreOnlyOSDisk)] public SwitchParameter RestoreOnlyOSDisk { get; set; } @@ -186,18 +186,18 @@ public class RestoreAzureRmRecoveryServicesBackupItem : RSBackupVaultCmdletBase /// [Parameter(Mandatory = false, ParameterSetName = AzureVMParameterSet, HelpMessage = ParamHelpMsgs.RestoreVM.RestoreDiskList)] - [Parameter(Mandatory = false, ParameterSetName = AzureVMUseOSAParameterSet, + [Parameter(Mandatory = false, ParameterSetName = AzureVMUnManagedDiskParameterSet, HelpMessage = ParamHelpMsgs.RestoreVM.RestoreDiskList)] - [Parameter(Mandatory = false, ParameterSetName = AzureVMTargetRGParameterSet, + [Parameter(Mandatory = false, ParameterSetName = AzureVMManagedDiskParameterSet, HelpMessage = ParamHelpMsgs.RestoreVM.RestoreDiskList)] - [Parameter(Mandatory = false, ParameterSetName = AzureVMRestoreAsUnmanaged, + [Parameter(Mandatory = false, ParameterSetName = AzureVMRestoreManagedAsUnmanaged, HelpMessage = ParamHelpMsgs.RestoreVM.RestoreDiskList)] public string[] RestoreDiskList { get; set; } /// /// Use this switch to specify to restore as unmanaged disks /// - [Parameter(Mandatory = true, ParameterSetName = AzureVMRestoreAsUnmanaged, + [Parameter(Mandatory = true, ParameterSetName = AzureVMRestoreManagedAsUnmanaged, HelpMessage = ParamHelpMsgs.RestoreVM.RestoreAsUnmanagedDisks)] public SwitchParameter RestoreAsUnmanagedDisks { get; set; } diff --git a/src/RecoveryServices/RecoveryServices/ChangeLog.md b/src/RecoveryServices/RecoveryServices/ChangeLog.md index fd41e25a3983..c8d40d85ad7a 100644 --- a/src/RecoveryServices/RecoveryServices/ChangeLog.md +++ b/src/RecoveryServices/RecoveryServices/ChangeLog.md @@ -18,6 +18,7 @@ - Additional information about change #1 --> ## Upcoming Release +* Making help text changes to Restore-AzRecoveryServicesBackupItem cmdlet. ## Version 3.0.1 * Specifying policy BackupTime is in UTC. diff --git a/src/RecoveryServices/RecoveryServices/help/Restore-AzRecoveryServicesBackupItem.md b/src/RecoveryServices/RecoveryServices/help/Restore-AzRecoveryServicesBackupItem.md index 2c5753e2f31f..17d2aef6a98d 100644 --- a/src/RecoveryServices/RecoveryServices/help/Restore-AzRecoveryServicesBackupItem.md +++ b/src/RecoveryServices/RecoveryServices/help/Restore-AzRecoveryServicesBackupItem.md @@ -10,7 +10,8 @@ schema: 2.0.0 ## SYNOPSIS -Restores the data and configuration for a Backup item to a recovery point. +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. ## SYNTAX @@ -22,16 +23,15 @@ Restore-AzRecoveryServicesBackupItem [-VaultLocation ] [-RecoveryPoint] [-Confirm] [] ``` -### AzureFileParameterSet +### AzureVMManagedDiskParameterSet ``` Restore-AzRecoveryServicesBackupItem [-VaultLocation ] [-RecoveryPoint] - -ResolveConflict [-SourceFilePath ] - [-SourceFileType ] [-TargetStorageAccountName ] [-TargetFileShareName ] - [-TargetFolder ] [-MultipleSourceFilePath ] [-VaultId ] + [-StorageAccountName] [-StorageAccountResourceGroupName] [-TargetResourceGroupName] + [-RestoreOnlyOSDisk] [-RestoreDiskList ] [-VaultId ] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` -### AzureVMRestoreAsUnmanaged +### AzureVMRestoreManagedAsUnmanaged ``` Restore-AzRecoveryServicesBackupItem [-VaultLocation ] [-RecoveryPoint] [-StorageAccountName] [-StorageAccountResourceGroupName] [-RestoreOnlyOSDisk] @@ -39,19 +39,20 @@ Restore-AzRecoveryServicesBackupItem [-VaultLocation ] [-RecoveryPoint] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` -### AzureVMTargetRGParameterSet +### AzureVMUnManagedDiskParameterSet ``` Restore-AzRecoveryServicesBackupItem [-VaultLocation ] [-RecoveryPoint] - [-StorageAccountName] [-StorageAccountResourceGroupName] [-TargetResourceGroupName] + [-StorageAccountName] [-StorageAccountResourceGroupName] [-UseOriginalStorageAccount] [-RestoreOnlyOSDisk] [-RestoreDiskList ] [-VaultId ] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` -### AzureVMUseOSAParameterSet +### AzureFileShareParameterSet ``` Restore-AzRecoveryServicesBackupItem [-VaultLocation ] [-RecoveryPoint] - [-StorageAccountName] [-StorageAccountResourceGroupName] [-UseOriginalStorageAccount] - [-RestoreOnlyOSDisk] [-RestoreDiskList ] [-VaultId ] + -ResolveConflict [-SourceFilePath ] + [-SourceFileType ] [-TargetStorageAccountName ] [-TargetFileShareName ] + [-TargetFolder ] [-MultipleSourceFilePath ] [-VaultId ] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` @@ -64,93 +65,81 @@ Restore-AzRecoveryServicesBackupItem [-VaultLocation ] [-WLRecoveryConfi ## 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 managed disks to a target resource group and configuration information to customer storage account -After the restore operation is finished, you must create the virtual machine and start it. -Please refter to different possible parameter sets and parameter text for more information. -Set the vault context by using the -VaultId parameter. -Note: To successfully execute this cmdlet in addition to -VaultId parameter -VaultLocation parameter should be used as well. +**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 an item to a recovery point +### Example 1: Restore the disks of a backed up Managed disk Azure VM from a given recovery point ```powershell PS C:\> $vault = Get-AzRecoveryServicesVault -ResourceGroupName "resourceGroup" -Name "vaultName" -PS C:\> $BackupItem = Get-AzRecoveryServicesBackupItem -BackupManagementType AzureVM -WorkloadType AzureVM -VaultId $vault.ID +PS C:\> $BackupItem = Get-AzRecoveryServicesBackupItem -BackupManagementType "AzureVM" -WorkloadType "AzureVM" -Name "V2VM" -VaultId $vault.ID PS C:\> $StartDate = (Get-Date).AddDays(-7) PS C:\> $EndDate = Get-Date -PS C:\> $RP = Get-AzRecoveryServicesBackupRecoveryPoint -Item $BackupItem[0] -StartDate $StartDate.ToUniversalTime() -EndDate $EndDate.ToUniversalTime() -VaultId $vault.ID -PS C:\> $restoreDiskLUNs = ("0", "1") -PS C:\> $RestoreJob = Restore-AzRecoveryServicesBackupItem -RecoveryPoint $RP[0] -TargetResourceGroupName "Target_RG" -StorageAccountName "DestAccount" -StorageAccountResourceGroupName "DestRG" -RestoreDiskList $restoreDiskLUNs -VaultId $vault.ID -VaultLocation $vault.Location +PS C:\> $RP = Get-AzRecoveryServicesBackupRecoveryPoint -Item $BackupItem -StartDate $StartDate.ToUniversalTime() -EndDate $EndDate.ToUniversalTime() -VaultId $vault.ID +PS C:\> $RestoreJob = Restore-AzRecoveryServicesBackupItem -RecoveryPoint $RP[0] -TargetResourceGroupName "Target_RG" -StorageAccountName "DestAccount" -StorageAccountResourceGroupName "DestRG" -VaultId $vault.ID -VaultLocation $vault.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 RecoveryServices vault and stores it in $vault variable. -The second command gets the Backup items and then stores it in the $BackupItem variable. +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 specifies which disks to restore from the recovery point and stores it in $restoreDiskLUNs variable. -The last command restores the disks to the target storage account DestAccount in the DestRG resource group. - -### Example 2: Restore Multiple files of an AzureFileShare item - -```powershell -PS C:\> $vault = Get-AzRecoveryServicesVault -ResourceGroupName "resourceGroup" -Name "vaultName" -PS C:\> $BackupItem = Get-AzRecoveryServicesBackupItem -BackupManagementType AzureStorage -WorkloadType AzureVM -VaultId $vault.ID -Name "fileshareitem" -PS C:\> $RP = Get-AzRecoveryServicesBackupRecoveryPoint -Item $BackupItem -VaultId $vault.ID -PS C:\> $files = ("file1.txt", "file2.txt") -PS C:\> $RestoreJob = Restore-AzRecoveryServicesBackupItem -RecoveryPoint $RP[0] -MultipleSourceFilePath $files -SourceFileType File -ResolveConflict Overwrite -VaultId $vault.ID -VaultLocation $vault.Location - 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 Backup container of type AzureVM, and then stores it in the $Container 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 spceifies which files to restore and stores it in $files variable. -The last command restores the specified files to its original location. - -### Example 3 - -Restores the data and configuration for a Backup item to a recovery point. (autogenerated) +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. -```powershell - -Restore-AzRecoveryServicesBackupItem -VaultId $vault.ID -WLRecoveryConfig -``` -### Example 4: Restore a managed VM as managed Disks +### Example 2: Restore specified disks of a backed up Managed disk Azure VM from a given recovery point ```powershell PS C:\> $vault = Get-AzRecoveryServicesVault -ResourceGroupName "resourceGroup" -Name "vaultName" -PS C:\> $BackupItem = Get-AzRecoveryServicesBackupItem -BackupManagementType AzureVM -WorkloadType AzureVM -VaultId $vault.ID +PS C:\> $BackupItem = Get-AzRecoveryServicesBackupItem -BackupManagementType "AzureVM" -WorkloadType "AzureVM" -Name "V2VM" -VaultId $vault.ID PS C:\> $StartDate = (Get-Date).AddDays(-7) PS C:\> $EndDate = Get-Date -PS C:\> $RP = Get-AzRecoveryServicesBackupRecoveryPoint -Item $BackupItem[0] -StartDate $StartDate.ToUniversalTime() -EndDate $EndDate.ToUniversalTime() -VaultId $vault.ID -PS C:\> $RestoreJob = Restore-AzRecoveryServicesBackupItem -RecoveryPoint $RP[0] -TargetResourceGroupName "Target_RG" -StorageAccountName "DestAccount" -StorageAccountResourceGroupName "DestRG" -VaultId $vault.ID -VaultLocation $vault.Location +PS C:\> $RP = Get-AzRecoveryServicesBackupRecoveryPoint -Item $BackupItem -StartDate $StartDate.ToUniversalTime() -EndDate $EndDate.ToUniversalTime() -VaultId $vault.ID +PS C:\> $restoreDiskLUNs = ("0", "1") +PS C:\> $RestoreJob = Restore-AzRecoveryServicesBackupItem -RecoveryPoint $RP[0] -TargetResourceGroupName "Target_RG" -StorageAccountName "DestAccount" -StorageAccountResourceGroupName "DestRG" -RestoreDiskList $restoreDiskLUNs -VaultId $vault.ID -VaultLocation $vault.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 RecoveryServices vault and stores it in $vault variable. -The second command gets the Backup item and then stores it in the $BackupItem variable. +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 restores the disks as managed disks with the given target resource group. +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 5: Restore a managed VM as unmanaged Disks +### Example 3: Restore disks of a managed VM as unmanaged Disks ```powershell PS C:\> $vault = Get-AzRecoveryServicesVault -ResourceGroupName "resourceGroup" -Name "vaultName" -PS C:\> $BackupItem = Get-AzRecoveryServicesBackupItem -BackupManagementType AzureVM -WorkloadType AzureVM -VaultId $vault.ID +PS C:\> $BackupItem = Get-AzRecoveryServicesBackupItem -BackupManagementType "AzureVM" -WorkloadType "AzureVM" -Name "V2VM" -VaultId $vault.ID PS C:\> $StartDate = (Get-Date).AddDays(-7) PS C:\> $EndDate = Get-Date PS C:\> $RP = Get-AzRecoveryServicesBackupRecoveryPoint -Item $BackupItem[0] -StartDate $StartDate.ToUniversalTime() -EndDate $EndDate.ToUniversalTime() -VaultId $vault.ID @@ -167,11 +156,11 @@ The fourth command gets the current date, and then stores it in the $EndDate var 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 6: Restore an unmanaged VM as unmanaged Disks using original storage account. +### Example 4: Restore an unmanaged VM as unmanaged Disks using original storage account ```powershell PS C:\> $vault = Get-AzRecoveryServicesVault -ResourceGroupName "resourceGroup" -Name "vaultName" -PS C:\> $BackupItem = Get-AzRecoveryServicesBackupItem -BackupManagementType AzureVM -WorkloadType AzureVM -VaultId $vault.ID +PS C:\> $BackupItem = Get-AzRecoveryServicesBackupItem -BackupManagementType AzureVM -WorkloadType AzureVM -Name "UnManagedVM" -VaultId $vault.ID PS C:\> $StartDate = (Get-Date).AddDays(-7) PS C:\> $EndDate = Get-Date PS C:\> $RP = Get-AzRecoveryServicesBackupRecoveryPoint -Item $BackupItem[0] -StartDate $StartDate.ToUniversalTime() -EndDate $EndDate.ToUniversalTime() -VaultId $vault.ID @@ -186,7 +175,58 @@ The second command gets the Backup item and then stores it in the $BackupItem va 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 using the original storage account of the VM. +The sixth command restores the disks as unmanaged disks to their original storage accounts + +### Example 5: Restore Multiple files of an AzureFileShare item + +```powershell +PS C:\> $vault = Get-AzRecoveryServicesVault -ResourceGroupName "resourceGroup" -Name "vaultName" +PS C:\> $BackupItem = Get-AzRecoveryServicesBackupItem -BackupManagementType AzureStorage -WorkloadType AzureVM -VaultId $vault.ID -Name "fileshareitem" +PS C:\> $RP = Get-AzRecoveryServicesBackupRecoveryPoint -Item $BackupItem -VaultId $vault.ID +PS C:\> $files = ("file1.txt", "file2.txt") +PS C:\> $RestoreJob = Restore-AzRecoveryServicesBackupItem -RecoveryPoint $RP[0] -MultipleSourceFilePath $files -SourceFileType File -ResolveConflict Overwrite -VaultId $vault.ID -VaultLocation $vault.Location + 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 6: Restore a SQL DB within an Azure VM to another target VM for a distinct full recovery point + +```powershell +PS C:\> $vault = Get-AzRecoveryServicesVault -ResourceGroupName "resourceGroup" -Name "vaultName" +PS C:\> $BackupItem = Get-AzRecoveryServicesBackupItem -BackupManagementType AzureWorkload -WorkloadType MSSQL -VaultId $vault.ID -Name "MSSQLSERVER;model" +PS C:\> $StartDate = (Get-Date).AddDays(-7) +PS C:\> $EndDate = Get-Date +PS C:\> $FullRP = Get-AzRecoveryServicesBackupRecoveryPoint -Item $BackupItem -StartDate $StartDate.ToUniversalTime() -EndDate $EndDate.ToUniversalTime() -VaultId $vault.ID +PS C:\> $TargetInstance = Get-AzRecoveryServicesBackupProtectableItem -WorkloadType MSSQL -ItemType SQLInstance -Name "" -ServerName "" -VaultId $vault.ID +PS C:\> $AnotherInstanceWithFullConfig = Get-AzRecoveryServicesBackupWorkloadRecoveryConfig -RecoveryPoint $FullRP -TargetItem $TargetInstance -AlternateWorkloadRestore -VaultId $vault.ID +PS C:\> Restore-AzRecoveryServicesBackupItem -WLRecoveryConfig $AnotherInstanceWithLogConfig -VaultId $vault.ID + WorkloadName Operation Status StartTime EndTime JobID + ------------ --------- ------ --------- ------- ----- + MSSQLSERVER/m... Restore InProgress 3/17/2019 10:02:45 AM 3274xg2b-e4fg-5952-89b4-8cb566gc1748 + +``` + +### Example 7: Restore a SQL DB within an Azure VM to another target VM for a log recovery point + +```powershell +PS C:\> $vault = Get-AzRecoveryServicesVault -ResourceGroupName "resourceGroup" -Name "vaultName" +PS C:\> $BackupItem = Get-AzRecoveryServicesBackupItem -BackupManagementType AzureWorkload -WorkloadType MSSQL -VaultId $vault.ID -Name "MSSQLSERVER;model" +PS C:\> $PointInTime = Get-Date -Date "2019-03-20 01:00:00Z" +PS C:\> $TargetInstance = Get-AzRecoveryServicesBackupProtectableItem -WorkloadType MSSQL -ItemType SQLInstance -Name "" -ServerName "" -VaultId $vault.ID +PS C:\> $AnotherInstanceWithLogConfig = Get-AzRecoveryServicesBackupWorkloadRecoveryConfig -PointInTime $PointInTime -Item $BackupItem -AlternateWorkloadRestore -VaultId $vault.ID +PS C:\> Restore-AzRecoveryServicesBackupItem -WLRecoveryConfig $AnotherInstanceWithLogConfig -VaultId $vault.ID + WorkloadName Operation Status StartTime EndTime JobID + ------------ --------- ------ --------- ------- ----- + MSSQLSERVER/m... Restore InProgress 3/17/2019 10:02:45 AM 3274xg2b-e4fg-5952-89b4-8cb566gc1748 + +``` ## PARAMETERS diff --git a/src/RecoveryServices/RecoveryServices/help/Set-AzRecoveryServicesBackupProtectionPolicy.md b/src/RecoveryServices/RecoveryServices/help/Set-AzRecoveryServicesBackupProtectionPolicy.md index 024a9c6c8bcc..982d17a736e2 100644 --- a/src/RecoveryServices/RecoveryServices/help/Set-AzRecoveryServicesBackupProtectionPolicy.md +++ b/src/RecoveryServices/RecoveryServices/help/Set-AzRecoveryServicesBackupProtectionPolicy.md @@ -38,10 +38,10 @@ Set the vault context by using the Set-AzRecoveryServicesVaultContext cmdlet bef ``` PS C:\> $SchPol = Get-AzRecoveryServicesBackupSchedulePolicyObject -WorkloadType "AzureVM" PS C:\> $SchPol.ScheduleRunTimes.Clear() -PS C:\> $Date = Get-Date -PS C:\> $date1 = Get-Date -Year $Date.Year -Month $Date.Month -Day $Date.Day -Hour $Date.Hour -Minute 0 -Second 0 -Millisecond 0 -PS C:\> $date1 = $date1.ToUniversalTime() -PS C:\> $SchPol.ScheduleRunTimes.Add($date1) +PS C:\> $Time = Get-Date +PS C:\> $Time1 = Get-Date -Year $Time.Year -Month $Time.Month -Day $Time.Day -Hour $Time.Hour -Minute 0 -Second 0 -Millisecond 0 +PS C:\> $Time1 = $Time1.ToUniversalTime() +PS C:\> $SchPol.ScheduleRunTimes.Add($Time1) PS C:\> $SchPol.ScheduleRunFrequency.Clear PS C:\> $SchPol.ScheduleRunDays.Add("Monday") PS C:\> $SchPol.ScheduleRunFrequency="Weekly" @@ -51,7 +51,9 @@ PS C:\> $RetPol.DailySchedule.DurationCountInDays = 0 PS C:\> $RetPol.IsWeeklyScheduleEnabled=$true PS C:\> $RetPol.WeeklySchedule.DaysOfTheWeek.Add("Monday") PS C:\> $RetPol.WeeklySchedule.DurationCountInWeeks = 365 -PS C:\> $Pol = Get-AzRecoveryServicesBackupProtectionPolicy -Name "TestPolicy" +PS C:\> $vault = Get-AzRecoveryServicesVault -ResourceGroupName "azurefiles" -Name "azurefilesvault" +PS C:\> $Pol= Get-AzRecoveryServicesBackupProtectionPolicy -Name "TestPolicy" -VaultId $vault.ID +PS C:\> $Pol.SnapshotRetentionInDays=5 PS C:\> Set-AzRecoveryServicesBackupProtectionPolicy -Policy $Pol -SchedulePolicy $SchPol -RetentionPolicy $RetPol ```