Database / Azure Cosmos DB interview questions
How does Cosmos DB backup and restore work?
Cosmos DB offers two backup modes, selected at account creation and switchable in some scenarios: Periodic backup (the legacy default) and Continuous backup (the recommended modern option).
Periodic Backup — Takes full snapshots at a configured interval (default every 4 hours, configurable to 1 or 2 hours). Snapshots are replicated to Azure Blob Storage in at least two regions. Retention is configurable (default 8 hours / 2 backup copies). Restoring from periodic backup creates a new Cosmos DB account — you cannot restore in place. Restore initiation requires contacting Azure Support, which adds time. Periodic backup cannot restore to a specific point in time between snapshots.
Continuous Backup (Point-in-Time Restore) — Continuously captures all changes as they happen, stored in backup storage. You can restore to any point in the last 7 or 30 days (two tiers) with minute-level granularity. Restore is self-service via the Azure portal, CLI, or API — no Support ticket needed. This is the mode for production applications where RTO (Recovery Time Objective) matters.
How to restore using Continuous backup via CLI:
az cosmosdb restore \
--account-name myRestored \
--target-resource-group myRG \
--source-account-name mySource \
--restore-timestamp "2024-05-10T14:30:00Z" \
--location eastusRestore always creates a new account — it is not an in-place operation. After restore, you point your application's connection string at the new account, verify data integrity, and then update DNS or configuration to cut over. Restores can take minutes to hours depending on data size.
Backup storage costs are separate from operational Cosmos DB billing. Continuous backup with 30-day retention costs significantly more than periodic backup, but for production workloads the self-service restore capability justifies the cost difference.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
