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!
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:
cp studio/sanity.cli.ts sanity.cli.ts
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!
Go to, or stay in, the variant.no
directory in your terminal of choice and run the following commands:
- Export the production dataset
sanity dataset export production production.tar.gz
- Delete the existing staging dataset
sanity dataset delete staging
- Import the production dataset
sanity dataset import production.tar.gz staging