az backup policy
In this we will learn about Azure backup policy for creating, deleting and for performing various others functions for the backup policy.
az backup policy create
Create a new policy for the given BackupManagementType and workloadType.
Azure CLI
az backup policy create –backup-management-type {AzureIaasVM, AzureStorage, AzureWorkload}
–name
–policy
–resource-group
–vault-name
[–subscription][–workload-type {AzureFileShare, MSSQL, SAPHANA, SAPHanaDatabase, SQLDataBase, VM}]
Examples
Create a new policy for the given BackupManagementType and workloadType.
Azure CLI
az backup policy create –policy {policy} –resource-group MyResourceGroup –vault-name MyVault –name MyPolicy –backup-management-type AzureStorage
Required Parameters
Firstly, –backup-management-type:
Specifiy the backup management type. Define how Azure Backup manages the backup of entities within the ARM resource.
Secondly, –name -n:
Name of the Policy.
Then, –policy:
JSON encoded policy definition. Use the show command with JSON output to obtain a policy object. Modify the values using a file editor and pass the object.
Next, –resource-group -g:
Name of resource group. You can configure the default group using az configure –defaults group=.
Lastly, –vault-name -v:
Name of the Recovery services vault.
az backup policy delete
Delete a backup policy which doesn’t have any associated backup items.
Azure CLI
az backup policy delete –name
[–ids][–resource-group][–subscription][–vault-name]
Examples
Before you can delete a Backup protection policy, the policy must not have any associated Backup items. However, to associate another policy with a Backup item, use the backup item set-policy command.
Azure CLI
az backup policy delete –name MyBackupPolicy –resource-group MyResourceGroup –vault-name MyVault
Required Parameters
–name -n:
Name of the backup policy. You can use the backup policy list command to get the name of a policy.
Optional Parameters
Firstly, –ids:
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of ‘Resource Id’ arguments.
Secondly, –resource-group -g:
Name of resource group. You can configure the default group using az configure –defaults group=.
Thirdly, –subscription:
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.
Lastly, –vault-name -v:
Name of the Recovery services vault.
az backup policy get-default-for-vm
Get the default policy with default values to backup a VM.
Azure CLI
az backup policy get-default-for-vm [–ids][–resource-group][–subscription][–vault-name]
Examples
Get the default policy with default values to backup a VM. (autogenerated)
Azure CLI
az backup policy get-default-for-vm –resource-group MyResourceGroup –vault-name MyVault
Optional Parameters
Firstly, –ids:
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of ‘Resource Id’ arguments.
Secondly, –resource-group -g:
Name of resource group. You can configure the default group using az configure –defaults group=.
Thirdly, –subscription:
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.
Then, –vault-name -v:
Name of the Recovery services vault.
az backup policy list-associated-items
List all items protected by a backup policy.
Azure CLI
az backup policy list-associated-items –name
[–backup-management-type {AzureIaasVM, AzureStorage, AzureWorkload}][–ids][–resource-group][–subscription][–vault-name]
Examples
List all items protected by a backup policy
Azure CLI
az backup policy list-associated-items –name MyBackupPolicy –resource-group MyResourceGroup –vault-name MyVault –backup-management-type AzureIaasVM
Required Parameters
Firstly, –name -n
Name of the backup policy. You can use the backup policy list command to get the name of a policy.
Optional Parameters
Firstly, –backup-management-type
Specifiy the backup management type. Define how Azure Backup manages the backup of entities within the ARM resource.
Secondly, –ids
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of ‘Resource Id’ arguments. However, you should provide either –ids or other ‘Resource Id’ arguments.
Thirdly, –resource-group -g
Name of resource group. You can configure the default group using az configure –defaults group=.
Then, –subscription
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.
Lastly, –vault-name -v
Name of the Recovery services vault.
az backup policy set
Update the existing policy with the provided details.
Azure CLI
az backup policy set [–backup-management-type {AzureIaasVM, AzureStorage, AzureWorkload}][–fix-for-inconsistent-items {false, true}][–ids][–name][–policy][–resource-group][–subscription][–vault-name]
Examples
Update the existing policy with the provided details. (autogenerated)
Azure CLI
az backup policy set –policy {policy} –resource-group MyResourceGroup –vault-name MyVault
Optional Parameters
Firstly, –backup-management-type
Specifiy the backup management type. Define how Azure Backup manages the backup of entities within the ARM resource.
Secondly, –fix-for-inconsistent-items
Specify whether or not to retry Policy Update for failed items.
Thirdly, –ids
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of ‘Resource Id’ arguments. You should provide either –ids or other ‘Resource Id’ arguments.
Next, –name -n
Name of the Policy.
Then, –policy
JSON encoded policy definition. Use the show command with JSON output to obtain a policy object. Modify the values using a file editor and pass the object.
–resource-group -g
Name of resource group. You can configure the default group using az configure –defaults group=.
Then, –subscription
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.
Lastly, –vault-name -v
Name of the Recovery services vault.
Reference: Microsoft Documentation