|
| 1 | +--- |
| 2 | +severity: Important |
| 3 | +pillar: Reliability |
| 4 | +category: RE:06 Data partitioning |
| 5 | +resource: Cosmos DB |
| 6 | +online version: https://azure.github.io/PSRule.Rules.Azure/en/rules/Azure.Cosmos.ContinuousBackup/ |
| 7 | +--- |
| 8 | + |
| 9 | +# Enable continuous backup policy |
| 10 | + |
| 11 | +## SYNOPSIS |
| 12 | + |
| 13 | +Enable continuous backup on Cosmos DB accounts. |
| 14 | + |
| 15 | +## DESCRIPTION |
| 16 | + |
| 17 | +Continuous backup for Azure Cosmos DB captures changes in near real-time, ensuring that you always have the most up-to-date backup. |
| 18 | +Data can be restored to any restorable timestamp within the retention period. |
| 19 | + |
| 20 | +Benefits of continuous backup include: |
| 21 | + |
| 22 | +- **Accidental Write or Delete Recovery**: Quickly recover from unintended changes within a container. |
| 23 | +- **Comprehensive Restoration**: Restore deleted accounts, databases, or containers. |
| 24 | +- **Regional Flexibility**: Restore data into any region where backups existed at the desired restore point. |
| 25 | +- **Ease of Use**: Restore data directly through the Azure portal without needing support requests. |
| 26 | + |
| 27 | +These features typically improve your: |
| 28 | + |
| 29 | +- **Recovery Time Objective (RTO)**: How long it take to recover, and systems are back online. |
| 30 | +- **Recovery Point Objective (RPO)**: The point in time you can recover to. |
| 31 | + |
| 32 | +Continuous backup involves additional costs, so it is recommended for mission-critical applications with frequent data changes. |
| 33 | + |
| 34 | +Check the documentation below for important information and limitations. |
| 35 | + |
| 36 | +## RECOMMENDATION |
| 37 | + |
| 38 | +Consider configuring Azure Cosmos DB with continuous backup mode for enhanced data protection (RTO & RPO) and easier recovery. |
| 39 | + |
| 40 | +## EXAMPLES |
| 41 | + |
| 42 | +### Configure with Azure template |
| 43 | + |
| 44 | +To configure continuous backup for Cosmos DB: |
| 45 | + |
| 46 | +- Set the `properties.backupPolicy.type` property to `Continuous`. |
| 47 | +- Set the `properties.backupPolicy.continuousModeProperties.tier` property to a valid tier. |
| 48 | + Valid tiers include `Continuous7Days` and `Continuous30Days`. |
| 49 | + |
| 50 | +For example: |
| 51 | + |
| 52 | +```json |
| 53 | +{ |
| 54 | + "type": "Microsoft.DocumentDB/databaseAccounts", |
| 55 | + "apiVersion": "2024-05-15", |
| 56 | + "name": "[parameters('name')]", |
| 57 | + "location": "[parameters('location')]", |
| 58 | + "kind": "GlobalDocumentDB", |
| 59 | + "properties": { |
| 60 | + "disableLocalAuth": true, |
| 61 | + "locations": [ |
| 62 | + { |
| 63 | + "locationName": "[parameters('location')]", |
| 64 | + "failoverPriority": 0, |
| 65 | + "isZoneRedundant": true |
| 66 | + } |
| 67 | + ], |
| 68 | + "backupPolicy": { |
| 69 | + "type": "Continuous", |
| 70 | + "continuousModeProperties": { |
| 71 | + "tier": "Continuous7Days" |
| 72 | + } |
| 73 | + } |
| 74 | + } |
| 75 | +} |
| 76 | +``` |
| 77 | + |
| 78 | +### Configure with Bicep |
| 79 | + |
| 80 | +To configure continuous backup for Cosmos DB: |
| 81 | + |
| 82 | +- Set the `properties.backupPolicy.type` property to `Continuous`. |
| 83 | +- Set the `properties.backupPolicy.continuousModeProperties.tier` property to a valid tier. |
| 84 | + Valid tiers include `Continuous7Days` and `Continuous30Days`. |
| 85 | + |
| 86 | +For example: |
| 87 | + |
| 88 | +```bicep |
| 89 | +resource account 'Microsoft.DocumentDB/databaseAccounts@2024-05-15' = { |
| 90 | + name: name |
| 91 | + location: location |
| 92 | + kind: 'GlobalDocumentDB' |
| 93 | + properties: { |
| 94 | + disableLocalAuth: true |
| 95 | + locations: [ |
| 96 | + { |
| 97 | + locationName: location |
| 98 | + failoverPriority: 0 |
| 99 | + isZoneRedundant: true |
| 100 | + } |
| 101 | + ] |
| 102 | + backupPolicy: { |
| 103 | + type: 'Continuous' |
| 104 | + continuousModeProperties: { |
| 105 | + tier: 'Continuous30Days' |
| 106 | + } |
| 107 | + } |
| 108 | + } |
| 109 | +} |
| 110 | +``` |
| 111 | + |
| 112 | +## NOTES |
| 113 | + |
| 114 | +Azure Cosmos DB API for Cassandra does not support continuous backup mode currently. |
| 115 | + |
| 116 | +## LINKS |
| 117 | + |
| 118 | +- [RE:06 Data partitioning](https://learn.microsoft.com/azure/well-architected/reliability/partition-data) |
| 119 | +- [Continuous backup with point-in-time restore in Azure Cosmos DB](https://learn.microsoft.com/azure/cosmos-db/continuous-backup-restore-introduction) |
| 120 | +- [Azure deployment reference](https://learn.microsoft.com/azure/templates/microsoft.documentdb/databaseaccounts) |
0 commit comments