How to export and re-import Sanity data for different projects/users?

2 replies
Last updated: Sep 22, 2023
its possible to export sanity data? and upload back on sanity if someone wants to reuse the application? for another user id etc
AI Update

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 production

This 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.gz

The 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 production

Setting Up for Different Users

For your use case of reusing the application for different users, here's a typical workflow:

  1. Export from the original project:

    sanity dataset export production original-content.tar.gz
  2. Set up a new Sanity project for the new user (with a different project ID)

  3. 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

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 thread
2 replies
Sure! The command line will show you options:
sanity dataset export --help
and
sanity dataset import --help
https://www.sanity.io/docs/export https://www.sanity.io/docs/importing-data
oh thats it, thank you very much

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.

Was this answer helpful?