Skip to content

Commit 5811268

Browse files
committed
Add Create A Local Sanity Dataset Backup as a Workflow TIL
1 parent d472a90 commit 5811268

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010

1111
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
1212

13-
_1344 TILs and counting..._
13+
_1345 TILs and counting..._
1414

1515
---
1616

@@ -1551,6 +1551,7 @@ _1344 TILs and counting..._
15511551

15521552
- [Change Window Name In iTerm](workflow/change-window-name-in-iterm.md)
15531553
- [Convert An ePub Document To PDF On Mac](workflow/convert-an-epub-document-to-pdf-on-mac.md)
1554+
- [Create A Local Sanity Dataset Backup](workflow/create-a-local-sanity-dataset-backup.md)
15541555
- [Create A Public URL For A Local Server](workflow/create-a-public-url-for-a-local-server.md)
15551556
- [Enable Dev Tools For Safari](workflow/enable-dev-tools-for-safari.md)
15561557
- [Forward Stripe Events To Local Server](workflow/forward-stripe-events-to-local-server.md)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Create A Local Sanity Dataset Backup
2+
3+
Let's say you've put together a script that is going to mutate some data in
4+
your production dataset on Sanity. Before you run that script, it would be
5+
prudent to capture a backup in case something goes wrong. That way you can
6+
always restore to how the data was in the event that you need to.
7+
8+
You can do this from the command line with the `sanity` CLI.
9+
10+
First, ensure you are signed in via the CLI.
11+
12+
```bash
13+
$ sanity login
14+
```
15+
16+
Then, you can issue the `dataset export` command, naming the dataset (in this
17+
case, `production`) to target and the name of the backup file to be created
18+
locally.
19+
20+
```bash
21+
$ sanity dataset export production my-project-backup.tar.gz
22+
```
23+
24+
I believe the Sanity CLI goes off the `sanity.cli.{ts,js}` file in your local
25+
project directory to determine what Sanity project it should be working with.
26+
27+
See the [`export dataset`](https://www.sanity.io/docs/dataset#fd38ca03b011)
28+
docs for more details.

0 commit comments

Comments
 (0)