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
Copy file name to clipboardExpand all lines: README.md
+38-2Lines changed: 38 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -246,13 +246,23 @@ Print the I2P hostname:
246
246
247
247
### Importing events from JSON Lines
248
248
249
-
You can import NIP-01 events from a `.jsonl` file directly into the relay database.
249
+
You can import NIP-01 events from `.jsonl` files directly into the relay database.
250
+
Compressed files are also supported and decompressed on-the-fly:
251
+
252
+
- `.jsonl.gz` (Gzip)
253
+
- `.jsonl.xz` (XZ)
250
254
251
255
Basic import:
252
256
```
253
257
npm run import -- ./events.jsonl
254
258
```
255
259
260
+
Import a compressed backup:
261
+
```
262
+
npm run import -- ./events.jsonl.gz
263
+
npm run import -- ./events.jsonl.xz
264
+
```
265
+
256
266
Set a custom batch size (default: `1000`):
257
267
```
258
268
npm run import -- ./events.jsonl --batch-size 500
@@ -636,16 +646,42 @@ To observe client and subscription counts in real-time during a test, you can in
636
646
```bash
637
647
docker compose logs -f nostream
638
648
```
639
-
640
649
## Export Events
641
650
642
651
Export all stored events to a [JSON Lines](https://jsonlines.org/) (`.jsonl`) file. Each line is a valid NIP-01 Nostr event JSON object. The export streams rows from the database using cursors, so it works safely on relays with millions of events without loading them into memory.
643
652
653
+
Optional compression is supported for lower storage and transfer costs:
654
+
655
+
- Gzip via Node's native `zlib`
656
+
- XZ via `lzma-native`
657
+
644
658
```
645
659
npm run export # writes to events.jsonl
646
660
npm run export -- backup-2024-01-01.jsonl # custom filename
661
+
npm run export -- backup.jsonl.gz --compress --format=gzip
662
+
npm run export -- backup.jsonl.xz --compress --format=xz
647
663
```
648
664
665
+
Flags:
666
+
667
+
-`--compress` / `-z`: enable compression.
668
+
-`--format <gzip|gz|xz>`: compression format. If omitted while compression is enabled,
669
+
format is inferred from file extension (`.gz` / `.xz`) and defaults to `gzip`.
670
+
671
+
After completion, the exporter prints a summary with:
672
+
673
+
- Raw bytes generated from JSONL lines
674
+
- Output bytes written to disk
675
+
- Compression delta (smaller/larger)
676
+
- Throughput in events/sec and bytes/sec
677
+
678
+
Optional XZ tuning (environment variables):
679
+
680
+
-`NOSTREAM_XZ_THREADS`: max worker threads for XZ compression.
681
+
Defaults to `4` and is automatically capped to available CPU cores minus one.
682
+
-`NOSTREAM_XZ_PRESET`: compression preset from `0` (fastest, larger output)
683
+
to `9` (slowest, smallest output). Default is `6`.
684
+
649
685
The script reads the same `DB_*` environment variables used by the relay (see [CONFIGURATION.md](CONFIGURATION.md)).
0 commit comments