Enable-AzRecoveryServicesBackupAutoProtection
The Enable-AzRecoveryServicesBackupAutoProtection cmdlet sets up automatic protection of current and any future SQL DBs within the given instance with the supplied policy.
Syntax
Default (Default)
Enable-AzRecoveryServicesBackupAutoProtection
[-InputItem] <ProtectableItemBase>
[-BackupManagementType] <BackupManagementType>
[-WorkloadType] <WorkloadType>
[-Policy] <PolicyBase>
[-PassThru]
[-VaultId <String>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
This command allows users to automatically protect all existing unprotected SQL DBs and any DB which will be added later with the given policy. Since the instruction is to back up all future DBs, the operation is done at a SQLInstance level, Azure backup service will then regularly scan auto-protected containers for any new DBs and automatically protect them.
Examples
Example 1
$Pol = Get-AzRecoveryServicesBackupProtectionPolicy -Name "DefaultSQLPolicy"
$SQLInstance = Get-AzRecoveryServicesBackupProtectableItem -workloadType MSSQL -ItemType SQLInstance -VaultId $targetVault.ID -Name "MSSQLInstance" -ServerName "TestSQLServer"
Enable-AzRecoveryServicesBackupAutoProtection -InputItem $SQLInstance -BackupManagementType AzureWorkload -WorkloadType MSSQL -Policy $Pol -VaultId $targetvault.ID
The first cmdlet gets a default policy object, and then stores it in the $Pol variable.
The second cmdlet fetches the relevant SQLInstance which is a protectable item. The 3rd command then sets up auto protection for this instance using the policy in $Pol.
Example 2
This commands allows users to automatically protect all existing unprotected DBs and any DB which will be added later with the given policy. (autogenerated)
Enable-AzRecoveryServicesBackupAutoProtection -BackupManagementType AzureVM -InputItem <ProtectableItemBase> -Policy $Pol -VaultId $vault.ID -WorkloadType AzureVM
Parameters
-BackupManagementType
The class of resources being protected. Currently the values supported for this cmdlet are MAB, AzureWorkload, AzureVM
Parameter properties
Type: BackupManagementType
Default value: None
Accepted values: AzureWorkload
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: 1
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Aliases: cf
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.
Parameter properties
Type: IAzureContextContainer
Default value: None
Supports wildcards: False
DontShow: False
Aliases: AzContext, AzureRmContext, AzureCredential
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
Specifies the protectable item object that can be passed as an input. The current supported value is a protectableItem object of type "SQLInstance".
(All)
Position: 0
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: False
Value from remaining arguments: False
-PassThru
Return the result for auto protection.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Policy
Protection policy object.
Parameter properties
Type: PolicyBase
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: 3
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-VaultId
ARM ID of the Recovery Services Vault.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: True
Value from pipeline by property name: False
Value from remaining arguments: False
-WhatIf
Shows what would happen if the cmdlet runs.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Aliases: wi
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-WorkloadType
Workload type of the resource. The current supported values are AzureVM, WindowsServer, MSSQL
Parameter properties
Type: WorkloadType
Default value: None
Accepted values: MSSQL, SAPHanaDatabase
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: 2
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters .
Outputs