Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
[assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright © Microsoft")]
[assembly: System.Reflection.AssemblyProductAttribute("Microsoft Azure PowerShell")]
[assembly: System.Reflection.AssemblyTitleAttribute("Microsoft Azure PowerShell - DataProtection")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("0.1.0.0")]
[assembly: System.Reflection.AssemblyVersionAttribute("0.1.0.0")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("2.10.0")]
[assembly: System.Reflection.AssemblyVersionAttribute("2.10.0")]
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)]
[assembly: System.CLSCompliantAttribute(false)]
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ function Initialize-AzDataProtectionRestoreRequest
[Hashtable]
${PrefixMatch},

[Parameter(ParameterSetName="AlternateLocationILR", Mandatory=$false, HelpMessage='Use this parameter to rename container(s) for alternate location ILR. Input for this parameter is a hashtable where each key is the original container name and each value is the new name for the corresponding container.')]
[Hashtable]
${RenameTo},

[Parameter(ParameterSetName="OriginalLocationILR", Mandatory=$false, HelpMessage='Specify the blob restore start range for PITR. You can use this option to specify the starting range for a subset of blobs in each container to restore. use a forward slash (/) to separate the container name from the blob prefix pattern.')]
# [Parameter(ParameterSetName="AlternateLocationILR", Mandatory=$false, HelpMessage='Minimum matching value for Item Level Recovery.')]
[System.String[]]
Expand Down Expand Up @@ -301,6 +305,7 @@ function Initialize-AzDataProtectionRestoreRequest

if(($RecoveryPoint -ne $null) -and ($RecoveryPoint -ne "") -and $ContainersList.length -gt 0){
$hasPrefixMatch = $PSBoundParameters.Remove("PrefixMatch")
$hasRenameTo = $PSBoundParameters.Remove("RenameTo")
for($i = 0; $i -lt $ContainersList.length; $i++){

$restoreCriteria = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20260301.ItemPathBasedRestoreCriteria]::new()
Expand All @@ -317,6 +322,17 @@ function Initialize-AzDataProtectionRestoreRequest
$restoreCriteria.SubItemPathPrefix = $pathPrefix
}

if($manifest.renameContainersEnabled -eq $true -and $hasRenameTo){
$renameToValue = $RenameTo[$ContainersList[$i]]
if($renameToValue -ne $null -and ($renameToValue -is [Array])){
throw "value for RenameTo must be a string for each container"
}
$restoreCriteria.RenameTo = $renameToValue
}
elseif( ($manifest.renameContainersEnabled -ne $true) -and ($hasRenameTo)){
throw "DatasourceType $DatasourceType does not support renaming containers"
}

# adding a criteria for each container given
$restoreCriteriaList += ($restoreCriteria)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Accept wildcard characters: False
Specifies whether to modify an existing LifeCycle.

```yaml
Type: System.Nullable`1[[System.Boolean, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
Type: System.Nullable`1[[System.Boolean, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
Parameter Sets: AddRetention
Aliases:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ Accept wildcard characters: False
Use system assigned identity

```yaml
Type: System.Nullable`1[[System.Boolean, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
Type: System.Nullable`1[[System.Boolean, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
Parameter Sets: (All)
Aliases:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Initialize-AzDataProtectionRestoreRequest -DatasourceType <DatasourceTypes> -Res
Initialize-AzDataProtectionRestoreRequest -DatasourceType <DatasourceTypes> -ItemLevelRecovery
-RestoreLocation <String> -RestoreType <RestoreTargetType> -SourceDataStore <DataStoreType>
-TargetResourceId <String> [-ContainersList <String[]>] [-PrefixMatch <Hashtable>] [-RecoveryPoint <String>]
[-RestoreConfiguration <PSObject>] [-UserAssignedIdentityArmId <String>]
[-RenameTo <Hashtable>] [-RestoreConfiguration <PSObject>] [-UserAssignedIdentityArmId <String>]
[-UseSystemAssignedIdentity <Boolean?>] [<CommonParameters>]
```

Expand Down Expand Up @@ -218,6 +218,30 @@ Note that the $aksRestoreCriteria object contains the necessary parameters for V
The RestoreConfiguration object is passed to the Initialize-AzDataProtectionRestoreRequest cmdlet to create the restore request object.
The restore request object is then used to trigger the restore operation.

### Example 8: Get restore request object for vaulted AzureBlob alternate location item level restore with container renaming
```powershell
$instance = Get-AzDataProtectionBackupInstance -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -ResourceGroupName "resourceGroupName" -VaultName "vaultName" | Where-Object { $_.Name -match "storageAccountName" }
$rp = Get-AzDataProtectionRecoveryPoint -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -ResourceGroupName "resourceGroupName" -VaultName "vaultName" -BackupInstanceName $instance.Name
$backedUpContainers = $instance.Property.PolicyInfo.PolicyParameter.BackupDatasourceParametersList[0].ContainersList
$renameTo = @{}
$renameTo[$backedUpContainers[0]] = "newContainerName1"
$renameTo[$backedUpContainers[1]] = "newContainerName2"
$targetStorageAccountId = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/targetStorageAccount"
$restoreReq = Initialize-AzDataProtectionRestoreRequest -DatasourceType AzureBlob -SourceDataStore VaultStore -RestoreLocation "vaultLocation" -RecoveryPoint $rp[0].Name -ItemLevelRecovery -RestoreType AlternateLocation -TargetResourceId $targetStorageAccountId -ContainersList $backedUpContainers[0,1] -RenameTo $renameTo
```

```output
ObjectType RestoreTargetInfoObjectType RestoreTargetInfoRecoveryOption RestoreTargetInfoRestoreLocation SourceDataStoreType RecoveryPointId
---------- --------------------------- ------------------------------- -------------------------------- ------------------- ---------------
AzureBackupRecoveryPointBasedRestoreRequest itemLevelRestoreTargetInfo FailIfExists vaultLocation VaultStore
```

The first and second commands fetch the backup instance and recovery points.
The third command retrieves the list of containers that are protected under the vaulted backup policy.
The fourth through sixth commands build a RenameTo hashtable that maps each original container name to a new container name for the restore.
The seventh command sets the target storage account ARM ID for the alternate location restore.
The last command initializes the restore request with -ItemLevelRecovery, -ContainersList, and -RenameTo to perform an alternate-location vaulted blob restore while renaming the specified containers.

## PARAMETERS

### -BackupInstance
Expand Down Expand Up @@ -391,6 +415,22 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -RenameTo
Use this parameter to rename container(s) for alternate location ILR.
Input for this parameter is a hashtable where each key is the original container name and each value is the new name for the corresponding container.

```yaml
Type: System.Collections.Hashtable
Parameter Sets: AlternateLocationILR
Aliases:

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

### -RestoreConfiguration
Restore configuration for restore.
Use this parameter to restore with AzureKubernetesService.
Expand Down Expand Up @@ -567,7 +607,7 @@ Accept wildcard characters: False
Use system assigned identity

```yaml
Type: System.Nullable`1[[System.Boolean, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
Type: System.Nullable`1[[System.Boolean, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
Parameter Sets: (All)
Aliases:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ Boolean parameter to decide whether cluster scope resources are included for bac
By default this is taken as true.

```yaml
Type: System.Nullable`1[[System.Boolean, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
Type: System.Nullable`1[[System.Boolean, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
Parameter Sets: (All)
Aliases:

Expand Down Expand Up @@ -267,7 +267,7 @@ Boolean parameter to decide whether snapshot volumes are included for backup.
By default this is taken as true.

```yaml
Type: System.Nullable`1[[System.Boolean, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
Type: System.Nullable`1[[System.Boolean, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
Parameter Sets: (All)
Aliases:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Boolean parameter to decide whether cluster scope resources are included for res
By default this is taken as true.

```yaml
Type: System.Nullable`1[[System.Boolean, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
Type: System.Nullable`1[[System.Boolean, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
Parameter Sets: (All)
Aliases:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ Accept wildcard characters: False
Use system assigned identity

```yaml
Type: System.Nullable`1[[System.Boolean, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
Type: System.Nullable`1[[System.Boolean, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
Parameter Sets: (All)
Aliases:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,27 @@ $aksALRRestoreRequest = Initialize-AzDataProtectionRestoreRequest -DatasourceTyp
First, we initialize the necessary variables that will be used in the restore script. Then, we fetch the backup instance and recovery point for the instance. Next, we initialize the Restore Configuration client object, which is used to set up the restore request client object. Note that for vaulted restore for AzureKubernetesService, we have passed the StagingResourceGroupId and StagingStorageAccountId parameters.

We then initialize the restore request object for an Azure Kubernetes Service (AKS) alternate location restore. Note that the $aksRestoreCriteria object contains the necessary parameters for Vaulted/operations tier restore accordingly. The RestoreConfiguration object is passed to the Initialize-AzDataProtectionRestoreRequest cmdlet to create the restore request object. The restore request object is then used to trigger the restore operation.

### Example 8: Get restore request object for vaulted AzureBlob alternate location item level restore with container renaming
```powershell
$instance = Get-AzDataProtectionBackupInstance -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -ResourceGroupName "resourceGroupName" -VaultName "vaultName" | Where-Object { $_.Name -match "storageAccountName" }
$rp = Get-AzDataProtectionRecoveryPoint -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -ResourceGroupName "resourceGroupName" -VaultName "vaultName" -BackupInstanceName $instance.Name
$backedUpContainers = $instance.Property.PolicyInfo.PolicyParameter.BackupDatasourceParametersList[0].ContainersList
$renameTo = @{}
$renameTo[$backedUpContainers[0]] = "newContainerName1"
$renameTo[$backedUpContainers[1]] = "newContainerName2"
$targetStorageAccountId = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/targetStorageAccount"
$restoreReq = Initialize-AzDataProtectionRestoreRequest -DatasourceType AzureBlob -SourceDataStore VaultStore -RestoreLocation "vaultLocation" -RecoveryPoint $rp[0].Name -ItemLevelRecovery -RestoreType AlternateLocation -TargetResourceId $targetStorageAccountId -ContainersList $backedUpContainers[0,1] -RenameTo $renameTo
```

```output
ObjectType RestoreTargetInfoObjectType RestoreTargetInfoRecoveryOption RestoreTargetInfoRestoreLocation SourceDataStoreType RecoveryPointId
---------- --------------------------- ------------------------------- -------------------------------- ------------------- ---------------
AzureBackupRecoveryPointBasedRestoreRequest itemLevelRestoreTargetInfo FailIfExists vaultLocation VaultStore
```

The first and second commands fetch the backup instance and recovery points.
The third command retrieves the list of containers that are protected under the vaulted backup policy.
The fourth through sixth commands build a RenameTo hashtable that maps each original container name to a new container name for the restore.
The seventh command sets the target storage account ARM ID for the alternate location restore.
The last command initializes the restore request with -ItemLevelRecovery, -ContainersList, and -RenameTo to perform an alternate-location vaulted blob restore while renaming the specified containers.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"generate_Id": "43c01683-17d5-4c10-a0f6-d8029b35f8de"
"generate_Id": "972d7a8e-adb7-48d6-89bb-7ebd1287c5be"
}
Loading
Loading