Best practices for backing up and restoring datasets in Sanity.io
Great questions about backing up your Sanity datasets! Let me walk you through the different options available.
Best way to backup a dataset
The best approach depends on your plan level:
For Enterprise plans: Sanity offers a managed backup feature that automatically creates daily backups of your dataset. This is the most robust solution with automated scheduling and retention policies (daily backups for 365 days, weekly backups for an additional 2 years).
For all plans: You can manually export your dataset using the Sanity CLI:
sanity dataset export productionThis creates a .tar.gz file containing all your documents and assets in NDJSON format.
Can you do it from the dashboard?
No, backups cannot be created directly from the dashboard. You'll need to use the Sanity CLI for both the managed backup feature (Enterprise) and manual exports (all plans).
Automatic scheduled backups
Enterprise plans only: Once you enable the backup service via CLI, Sanity automatically performs daily backups:
sanity backup enable productionYour first backup will be available within 24 hours, and the service continues running daily after that.
For other plans: You'll need to set up your own automation. A popular approach is using GitHub Actions to schedule regular exports and store them as artifacts or in cloud storage (S3, Google Cloud Storage, etc.).
How to restore from a backup
Use the sanity dataset import command:
sanity dataset import backup-2024.tar.gz productionImportant gotcha: If you're importing into a different dataset than the backup originated from, add the --allow-assets-in-different-dataset flag.
For detailed restoration steps, check out the guide on restoring a deleted dataset from a backup.
Creating a development dataset from production backup
Yes, absolutely! This is a common workflow. Here's how:
- Export your production dataset:
sanity dataset export production production-backup.tar.gz- Create a new development dataset (if it doesn't exist):
sanity dataset create development- Import the backup into development:
sanity dataset import production-backup.tar.gz development --allow-assets-in-different-datasetThe --allow-assets-in-different-dataset flag is required when importing across different datasets.
Enterprise alternative: Cloud Clone
If you're on an Enterprise plan, there's also Cloud Clone which duplicates datasets directly in Sanity's cloud infrastructure without downloading anything locally - much faster for large datasets!
What's included in backups?
Backups contain:
- All documents (including hidden ones used by Studio and plugins)
- All assets (images and files)
Not included:
- Schema definitions (these live in your Studio code)
- Comments
- Document history/revision timeline
Hope this helps! The CLI export approach works for everyone, while the managed backup feature provides enterprise-grade automation and retention policies.
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.