1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 15:18:01 +00:00

Add Create A Local Sanity Dataset Backup as a Workflow TIL

This commit is contained in:
jbranchaud
2023-10-25 11:15:54 -05:00
parent d472a900c7
commit 5811268d3f
2 changed files with 30 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
# Create A Local Sanity Dataset Backup
Let's say you've put together a script that is going to mutate some data in
your production dataset on Sanity. Before you run that script, it would be
prudent to capture a backup in case something goes wrong. That way you can
always restore to how the data was in the event that you need to.
You can do this from the command line with the `sanity` CLI.
First, ensure you are signed in via the CLI.
```bash
$ sanity login
```
Then, you can issue the `dataset export` command, naming the dataset (in this
case, `production`) to target and the name of the backup file to be created
locally.
```bash
$ sanity dataset export production my-project-backup.tar.gz
```
I believe the Sanity CLI goes off the `sanity.cli.{ts,js}` file in your local
project directory to determine what Sanity project it should be working with.
See the [`export dataset`](https://www.sanity.io/docs/dataset#fd38ca03b011)
docs for more details.