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