Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is unclear how to use az backup policy create in conjunction of -PolicySubType "Enhanced" #124804

Open
V4A001 opened this issue Nov 7, 2024 · 3 comments

Comments

@V4A001
Copy link

V4A001 commented Nov 7, 2024

Documention is unclear on how to create an enhanced policy. It seems that - and -- are used. And the azure cli command do not work.

It is unclear how to use az backup policy create in conjunction of -PolicySubType "Enhanced"

Please provide better example and/or update documentation with working samples. Using list to get an online through GUI created policy and pushing it back with create does not work at all.

My code:

`backupResourceGroupName="RecoveryVaultProd"
serverrecoveryvault="servers-recovery-vault-prod"
retentionpolicyname="servers-retention-policy"

Create vault in separate resource group

az group create --name $backupResourceGroupName --location $location

az backup vault create
--resource-group $backupResourceGroupName
--name $serverrecoveryvault
--location $location

az backup vault backup-properties set
--resource-group $backupResourceGroupName
--name $serverrecoveryvault
--backup-storage-redundancy "GeoRedundant"

customPolicy=$(cat <<EOF
{
"name": "${retentionpolicyname}",
"properties": {
"backupManagementType": "AzureIaasVM",
"instantRpDetails": {
"azureBackupRgNamePrefix": null,
"azureBackupRgNameSuffix": null
},
"instantRpRetentionRangeInDays": 2,
"policyType": "V2",
"protectedItemsCount": 0,
"resourceGuardOperationRequests": null,
"retentionPolicy": {
"dailySchedule": {
"retentionDuration": {
"count": 30,
"durationType": "Days"
},
"retentionTimes": [
"2024-11-07T18:00:00+00:00"
]
},
"monthlySchedule": {
"retentionDuration": {
"count": 12,
"durationType": "Months"
},
"retentionScheduleDaily": null,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2024-11-07T18:00:00+00:00"
]
},
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": null,
"yearlySchedule": null
},
"schedulePolicy": {
"dailySchedule": {
"scheduleRunTimes": [
"2024-11-07T18:00:00+00:00"
]
},
"hourlySchedule": null,
"schedulePolicyType": "SimpleSchedulePolicyV2",
"scheduleRunFrequency": "Daily",
"weeklySchedule": null
},
"snapshotConsistencyType": null,
"tieringPolicy": {
"ArchivedRP": {
"duration": 0,
"durationType": "Invalid",
"tieringMode": "DoNotTier"
}
},
"timeZone": "W. Europe Standard Time"
},
"resourceGroup": "${backupResourceGroupName}",
"tags": null,
"type": "Microsoft.RecoveryServices/vaults/backupPolicies"
}
EOF
)

echo $customPolicy

az backup policy create
--resource-group $backupResourceGroupName
--vault-name $serverrecoveryvault
--name $retentionpolicyname
--backup-management-type AzureIaasVM
--workload-type VM
--policy $customPolicy

list policies of type enhanced

az backup policy list
--resource-group $backupResourceGroupName
--vault-name $serverrecoveryvault
--backup-management-type AzureIaasVM
--workload-type VM
--policy-sub-type Enhanced

az backup protection enable-for-vm
--resource-group $printerserverGroupName
--vault-name $serverrecoveryvault
--vm $printservervmName
--policy-name $retentionpolicyname

vmid=$(az vm show -g $printerserverGroupName -n $printservervmName --query id | tr -d '"')
echo $vmid

az backup protection enable-for-vm
--resource-group $backupResourceGroupName
--vault-name $serverrecoveryvault
--vm $vmid
--policy-name "EnhancedPolicy"
--policy-name $retentionpolicyname`

@TPavanBalaji
Copy link
Contributor

@V4A001
It would be great if you could add a link to the documentation you are following for these steps? This would help us redirect the issue to the appropriate team. Thanks!

@V4A001
Copy link
Author

V4A001 commented Nov 8, 2024

@TPavanBalaji
Copy link
Contributor

@V4A001
Thank you for bringing this to our attention.
I've delegated this to content author, who will review it and offer their insightful opinions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants