How to back up your Sanity dataset using CLI or plugins.
You're right that there's no UI option for backing up datasets—this is done through the Sanity CLI. Here's how to back up your entire dataset including assets:
Quick Backup Command
The simplest way to export your entire dataset is:
sanity dataset export productionThis creates a production.tar.gz file in your current directory containing all your documents and assets.
You can also specify a custom filename and location:
sanity dataset export production ./backups/backup-2024-01-15.tar.gzWhat Gets Included
The export includes:
- All your documents (published and draft versions)
- All assets (images, files, videos)
- Hidden documents used by Studio and plugins
Note: The export doesn't include your schema definition (that lives in your Studio code) or access control settings.
Export Formats
By default, you get a tar.gz archive with documents in NDJSON format plus assets in separate folders. If you only need documents without assets, you can export to NDJSON format instead.
Restoring from Backup
If you ever need to restore, use the import command:
sanity dataset import backup-2024-01-15.tar.gz productionBest Practices
Since Sanity doesn't provide built-in backup storage, you should:
- Store exports in cloud storage (AWS S3, Google Cloud Storage, etc.)
- Set up automated backups using GitHub Actions
- Always create a backup before running content migrations
For enterprise plans, there's also a managed Backup feature with retention policies and a Cloud Clone feature for server-side dataset copying without downloading locally.
Make sure you have the Sanity CLI installed (npm install -g @sanity/cli) and are authenticated (sanity login) before running export commands!
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.