You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Created by [@alanshurafa](https://github.com/alanshurafa)**
8
+
9
+
</div>
10
+
3
11
Export all Open Brain Supabase tables to local JSON files. The script paginates through PostgREST (1 000 rows per request), writes each table to a dated JSON file, and prints a summary.
4
12
5
13
## Prerequisites
@@ -31,10 +39,27 @@ Export all Open Brain Supabase tables to local JSON files. The script paginates
31
39
32
40
## Expected Result
33
41
34
-
After running the script you will have a `backup/` directory containing dated JSON exports of every Open Brain table (thoughts, entities, edges, thought_entities, reflections, ingestion_jobs, ingestion_items). The console output shows row counts and file sizes for each table, making it easy to verify the backup is complete.
42
+
After running the script you will have a `backup/` directory containing dated JSON exports of every Open Brain table present in your project.
43
+
44
+
-`thoughts` is always backed up (required).
45
+
- Optional companion tables — `entities`, `edges`, `thought_entities`, `ingestion_jobs`, `ingestion_items` — are backed up only if they exist. They ship with companion contributions (e.g. the entity-extraction and smart-ingest schemas). Stock Open Brain installs will see `skipped (table not present)` for those, which is expected.
46
+
47
+
The console output shows row counts and file sizes for each table, making it easy to verify the backup is complete.
35
48
36
49
## Tips
37
50
38
51
- Schedule the script with cron or Task Scheduler for automatic daily backups.
39
52
- Commit the `backup/` directory to a private repo for versioned history.
40
53
- The script streams rows to disk, so it handles large tables without running out of memory.
54
+
55
+
## Troubleshooting
56
+
57
+
-**`PostgREST error 404 on thoughts`** -- the script could reach the server but the `thoughts` table isn't visible to it. Only a PostgREST "schema cache" 404 (`code: "PGRST205"`) is treated as "table not present"; everything else is surfaced so you can diagnose it. Common causes:
58
+
- Typo in `SUPABASE_URL` (for example pointing at `/v1` instead of the project root -- the script appends `/rest/v1` itself).
59
+
- Supabase project is paused or deleted.
60
+
- The `thoughts` table lives in a non-`public` schema that PostgREST isn't exposing.
61
+
- You're using the `anon` key instead of the `service_role` key. The anon key can be restricted by RLS and return empty or 404 responses; service-role keys bypass RLS.
62
+
-**`skipped (table not present)` for optional tables** -- expected on stock Open Brain installs. The optional tables ship with companion contributions (entity extraction, smart ingest).
63
+
-**`PostgREST error 401`** -- `SUPABASE_SERVICE_ROLE_KEY` is wrong, revoked, or truncated.
64
+
-**`PostgREST error 403`** -- unusual for service-role keys, which should bypass RLS. Double-check you're not using a custom-minted JWT with narrower claims.
65
+
-**Script hangs or aborts after ~60s** -- set `FETCH_TIMEOUT_MS` to a larger value (milliseconds) if your project is on a slow tier or has very large tables.
0 commit comments