Skip to content

Latest commit

 

History

History
46 lines (30 loc) · 1.17 KB

import-sanity-dataset.md

File metadata and controls

46 lines (30 loc) · 1.17 KB

Importing Sanity datasets

Occasionally, we might want to get a fresh dump of the production dataset in Sanity and import it into the staging dataset to avoid having stale data in our local development environments. Here's how you can do that!

Preparations

First, copy the Sanity CLI config from either studio/ or studioShared/, depending on what studio you're working in. Assuming you are in the root of the project, i.e. the variant.no directory, run one of the following commands in your terminal of choice:

Studio

cp studio/sanity.cli.ts sanity.cli.ts

Shared studio

cp studioShared/sanity.cli.ts sanity.cli.ts

This will ensure that we read the correct environment variables to connect to the given studio. With that set up, we can get going!

Import and export

Go to, or stay in, the variant.no directory in your terminal of choice and run the following commands:

  1. Export the production dataset
sanity dataset export production production.tar.gz
  1. Delete the existing staging dataset
sanity dataset delete staging
  1. Import the production dataset
sanity dataset import production.tar.gz staging