How to export and re-import Sanity data for different projects/users?
Yes, absolutely! Sanity makes it straightforward to export and import dataset content, which is perfect for backing up data, migrating between projects, or setting up new instances of your application for different users.
Exporting Your Data
You can export your entire dataset using the Sanity CLI:
sanity dataset export productionThis creates a production.tar.gz file containing all your documents and assets. You can also specify a custom filename:
sanity dataset export production ./backups/my-backup.tar.gzThe export includes:
- All documents across all content types
- All uploaded assets (images, files)
- Hidden configuration documents used by Studio and plugins
Note: The export doesn't include your schema definition (that lives in your Studio code) or custom access control settings.
Importing Data Back
To import the data into another dataset or project:
# Import to a different dataset in the same project
sanity dataset import production.tar.gz staging
# Or import to a completely different project
# (first navigate to the new project directory)
sanity dataset import /path/to/backup.tar.gz productionSetting Up for Different Users
For your use case of reusing the application for different users, here's a typical workflow:
Export from the original project:
sanity dataset export production original-content.tar.gzSet up a new Sanity project for the new user (with a different project ID)
Import the data:
cd new-project-directory sanity dataset import /path/to/original-content.tar.gz production
This gives you a complete copy of the content in a new project with separate billing and access controls.
Alternative: Cross Dataset Duplicator Plugin
If you need to migrate content between projects frequently from within Studio, check out the Cross Dataset Duplicator plugin which provides a UI for copying documents and assets between projects.
Best Practices
- Always backup before migrations: Export your dataset before making major schema changes
- Automate backups: Consider setting up automated backups using GitHub Actions
- Store exports securely: Sanity doesn't provide backup storage, so keep exports in cloud storage (S3, Google Cloud Storage, etc.)
For enterprise users, there's also a Cloud Clone feature that duplicates datasets server-side without downloading locally, and managed backup features with retention policies.
Show original thread2 replies
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.