{ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json##", "contentVersion": "1.0.0.0", "parameters": { "companyname": { "type": "string", "defaultValue": "rg1", "metadata": { "description": "Default name for everything" } }, "location": { "type": "string", "defaultValue": "westeurope", "allowedValues": [ "westeurope", "northeurope" ], "metadata": { "description": "Location for the resourceGroup" } }, "scheduleRunDays": { "type": "array", "metadata": { "description": "Backup Schedule will run on array of Days like, Monday, Tuesday etc. Applies in Weekly Backup Type only." } }, "scheduleRunTimes": { "type": "array", "metadata": { "description": "Times in day when backup should be triggered. e.g. 01:00, 13:00. This will be used in LTR too for daily, weekly, monthly and yearly backup." } }, "timeZone": { "type": "string", "metadata": { "description": "Any Valid timezone, for example:UTC, Pacific Standard Time. Refer: https://msdn.microsoft.com/en-us/library/gg154758.aspx" } }, "weeklyRetentionDurationCount": { "type": "int", "metadata": { "description": "Number of weeks you want to retain the backup" } }, "daysOfTheWeekForMontlyRetention": { "type": "array", "metadata": { "description": "Array of Days for Monthly Retention (Min One or Max all values from scheduleRunDays, but not any other days which are not part of scheduleRunDays)" } }, "weeksOfTheMonthForMonthlyRetention": { "type": "array", "metadata": { "description": "Array of Weeks for Monthly Retention - First, Second, Third, Fourth, Last" } }, "monthlyRetentionDurationCount": { "type": "int", "metadata": { "description": "Number of months you want to retain the backup" } }, "monthsOfYear": { "type": "array", "metadata": { "description": "Array of Months for Yearly Retention" } }, "daysOfTheWeekForYearlyRetention": { "type": "array", "metadata": { "description": "Array of Days for Yearly Retention (Min One or Max all values from scheduleRunDays, but not any other days which are not part of scheduleRunDays)" } }, "weeksOfTheMonthForYearlyRetention": { "type": "array", "metadata": { "description": "Array of Weeks for Yearly Retention - First, Second, Third, Fourth, Last" } }, "yearlyRetentionDurationCount": { "type": "int", "metadata": { "description": "Number of years you want to retain the backup" } } }, "variables": { "rgName": "[toLower(concat('rg_', parameters('companyname')))]", "vnetName": "[toLower(concat('vnet-', parameters('companyname')))]", "vmName": "[toLower(concat('vm-', parameters('companyname')))]", "vaultName": "[toLower(concat('vault-', parameters('companyname')))]", "backupPolicyName": "[toLower(concat('backupPolicy-', parameters('companyname')))]", }, "resources": [ { "apiVersion": "2020-02-02", "name": "[variables('vaultName')]", "location": "[parameters('location')]", "type": "Microsoft.RecoveryServices/vaults", "sku": { "name": "RS0", "tier": "Standard" }, "properties": {}, "tags": { "owner": "ict", "ciarating": "333" } }, { "apiVersion": "2016-12-01", "name": "[concat(variables('vaultName'), '/', variables('backupPolicyName'))]", "type": "Microsoft.RecoveryServices/vaults/backupPolicies", "dependsOn": [ "[concat('Microsoft.RecoveryServices/vaults/', variables('vaultName'))]" ], "location": "[parameters('location')]", "properties": { "backupManagementType": "AzureIaasVM", "instantRpRetentionRangeInDays": 5, "schedulePolicy": { "scheduleRunFrequency": "Weekly", "scheduleRunDays": "[parameters('scheduleRunDays')]", "scheduleRunTimes": "[parameters('scheduleRunTimes')]", "schedulePolicyType": "SimpleSchedulePolicy" }, "retentionPolicy": { "dailySchedule": null, "weeklySchedule": { "daysOfTheWeek": "[parameters('scheduleRunDays')]", "retentionTimes": "[parameters('scheduleRunTimes')]", "retentionDuration": { "count": "[parameters('weeklyRetentionDurationCount')]", "durationType": "Weeks" } }, "monthlySchedule": { "retentionScheduleFormatType": "Weekly", "retentionScheduleDaily": { "daysOfTheMonth": [ { "date": 1, "isLast": false } ] }, "retentionScheduleWeekly": { "daysOfTheWeek": "[parameters('daysOfTheWeekForMontlyRetention')]", "weeksOfTheMonth": "[parameters('weeksOfTheMonthForMonthlyRetention')]" }, "retentionTimes": "[parameters('scheduleRunTimes')]", "retentionDuration": { "count": "[parameters('monthlyRetentionDurationCount')]", "durationType": "Months" } }, "yearlySchedule": { "retentionScheduleFormatType": "Weekly", "monthsOfYear": "[parameters('monthsOfYear')]", "retentionScheduleDaily": { "daysOfTheMonth": [ { "date": 1, "isLast": false } ] }, "retentionScheduleWeekly": { "daysOfTheWeek": "[parameters('daysOfTheWeekForYearlyRetention')]", "weeksOfTheMonth": "[parameters('weeksOfTheMonthForYearlyRetention')]" }, "retentionTimes": "[parameters('scheduleRunTimes')]", "retentionDuration": { "count": "[parameters('yearlyRetentionDurationCount')]", "durationType": "Years" } }, "retentionPolicyType": "LongTermRetentionPolicy" }, "timeZone": "[parameters('timeZone')]" } } ] }