You may, or may not, be aware that CosmosDB units are backed-up automatically by the great guys at Microsoft. Not only that, you have some flexibility over both the frequency and retention of the backups.
In order to define the frequency and retention, there are two metrics which you need to determine. These are:
- the frequency of backups – say these are denoted by backupIntervalInMinutes; and,
- the length of time backup snapshots are stored – say denoted by backupRetentionPeriodInHours
As part of this service, there are a few limits of which you need to be aware. These are:
- backupIntervalInMinutes must be >= 60minutes
- backupRetentionPeriodInHours has to be <= 100hours
However, the most important limit to note is…
…the combination, of the Backup Interval and Backup Retention, cannot exceed more than 25 copies
Therefore, the following formula can be used to determine the number of copies you can have with these settings:
As an example, you might derive the following backup policy:
hourly backups which are retained for one day
This means, the parameters will be defined as follows:
- backupIntervalInMinutes = 60mins
- backupRetentionPeriodInHours = 24hours
Using the above formula, we work out the number of copies we can have with this policy, baring in mind it must be less than or equal to 25:
When deploying a Production instance of CosmosDB, you’ll appreciate how important it will be to understand the configuration of these backups, to match the non-Functional requirements (NFR’s) for your customer.
If you don’t know the configuration of the backups for your CosmosDB unit, you should raise a ticket with Microsoft, for confirmation or, for assistance to redefine your policy.