Modifier

Partager via


Initialize-AzDataProtectionBackupInstance

Initializes Backup instance Request object for configuring backup

Syntax

Initialize-AzDataProtectionBackupInstance
          -DatasourceType <DatasourceTypes>
          -DatasourceLocation <String>
          [-PolicyId <String>]
          [-DatasourceId <String>]
          [-SecretStoreURI <String>]
          [-SecretStoreType <SecretStoreTypes>]
          [-SnapshotResourceGroupId <String>]
          [-FriendlyName <String>]
          [-BackupConfiguration <IBackupDatasourceParameters>]
          [<CommonParameters>]

Description

Initializes Backup instance Request object for configuring backup

Examples

Example 1: Initialize Backup instance object for Azure Disk

$policy = Get-AzDataProtectionBackupPolicy -SubscriptionId "xxxx-xxx-xxx" -ResourceGroupName sarath-rg -VaultName sarath-vault
$AzureDiskId = "/subscriptions/{subscription}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{diskname}"
$instance = Initialize-AzDataProtectionBackupInstance -DatasourceType AzureDisk -DatasourceLocation westus -DatasourceId $AzureDiskId -PolicyId $policy[0].Id
$instance.Property.PolicyInfo.PolicyParameter.DataStoreParametersList[0].ResourceGroupId = "/subscriptions/{subscription}/resourceGroups/{snapshotResourceGroup}"
$instance

Name Type BackupInstanceName
---- ---- ------------------
          sarath-disk3-sarath-disk3-af697a80-e2bc-49f1-af6c-22f6c4d68405

The First command gets all the policies in a given vault. The second command stores azure disk's resource id in $AzureDiskId variable. The third command returns a backup instance resource for Azure Disk. The fourth command sets the snapshot resource group field. This object can now be used to configure backup for the given disk.

Example 2: Initialize Backup instance object for AzureKubernetesService

$policy = Get-AzDataProtectionBackupPolicy -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -VaultName "vaultName" -ResourceGroupName "resourceGroupName" | Where-Object {$_.Name -eq "policyName"}
$sourceClusterId = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/resourceGroupName/providers/Microsoft.ContainerService/managedClusters/aks-cluster"
$snapshotResourceGroupId = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/resourceGroupName"
$backupConfig = New-AzDataProtectionBackupConfigurationClientObject -SnapshotVolume $true -IncludeClusterScopeResource $true -DatasourceType AzureKubernetesService -LabelSelector "x=y","foo=bar" 
$backupInstance = Initialize-AzDataProtectionBackupInstance -DatasourceType AzureKubernetesService  -DatasourceLocation "eastus" -PolicyId $policy.Id -DatasourceId $sourceClusterId -SnapshotResourceGroupId $snapshotResourceGroupId -FriendlyName "aks-cluster-friendlyName" -BackupConfiguration $backupConfig
$instance

Name BackupInstanceName
---- ------------------
     aks-cluster-aks-cluster-ed68435e-069t-4b4a-9d84-d0c194800fc2

The First command gets the AzureKubernetesService policy in a given vault. The second, third command initializes the AKS cluster and snapshot resource group Id. The fourth command backup configuration object needed for AzureKubernetesService. The fifth command initializes the client object for backup instance. This object can now be used to configure backup using New-AzDataProtectionBackupInstance after all necessary permissions are assigned with Set-AzDataProtectionMSIPermission command.

Example 3: Configure protection for AzureDatabaseForPGFlexServer

$vault = Get-AzDataProtectionBackupVault -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -ResourceGroupName "resourceGroupName" -VaultName "vaultName"
$pol = Get-AzDataProtectionBackupPolicy -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -VaultName "vaultName" -ResourceGroupName "resourceGroupName" -Name "policyName"
$datasourceId = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/rgName/providers/Microsoft.DBforPostgreSQL/flexibleServers/test-pgflex"
$backupInstanceClientObject = Initialize-AzDataProtectionBackupInstance -DatasourceType AzureDatabaseForPGFlexServer -DatasourceLocation $vault.Location -PolicyId $pol[0].Id -DatasourceId $datasourceId

Name BackupInstanceName
---- ------------------
     test-pgflex-test-pgflex-ed68435e-069t-4b4a-9d84-d0c194800fc2

The first command gets the backup vault. The second command get the AzureDatabaseForPGFlexServer policy. The third command datasource ARM Id. The fourth command initializes the backup instance. Similarly use datasourcetype AzureDatabaseForMySQL to initialize backup instance for AzureDatabaseForMySQL.

Parameters

-BackupConfiguration

Backup configuration for backup. Use this parameter to configure protection for AzureKubernetesService,AzureBlob. To construct, see NOTES section for BACKUPCONFIGURATION properties and create a hash table.

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

-DatasourceId

ID of the datasource to be protected

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

-DatasourceLocation

Location of the Datasource to be protected.

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

-DatasourceType

Datasource Type

Type:DatasourceTypes
Accepted values:AzureDisk, AzureBlob, AzureDatabaseForPostgreSQL, AzureKubernetesService, AzureDatabaseForPGFlexServer, AzureDatabaseForMySQL
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-FriendlyName

Friendly name for backup instance

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

-PolicyId

Policy Id to be assiciated to Datasource

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

-SecretStoreType

Secret store type for secret store authentication of data source. This parameter is only supported for AzureDatabaseForPostgreSQL currently.

Type:SecretStoreTypes
Accepted values:AzureKeyVault
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-SecretStoreURI

Secret uri for secret store authentication of data source. This parameter is only supported for AzureDatabaseForPostgreSQL currently.

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

-SnapshotResourceGroupId

Sanpshot Resource Group

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

Outputs

IBackupInstanceResource