Surreal-Sync – Datenmigration und Synchronisation
Surreal-Sync ist ein CLI-Tool zur Migration von Daten aus verschiedenen Datenbankquellen nach SurrealDB mit vollständiger und inkrementeller Synchronisation mittels Change Data Capture (CDC).
Unterstützte Quellen
| Quelle | Vollständige Synchronisation | Inkrementelles CDC | Methode |
|---|---|---|---|
| MongoDB | Ja | Ja | Change Streams |
| MySQL | Ja | Ja | Trigger-basiertes CDC + Sequenz-Checkpoints |
| PostgreSQL (Trigger) | Ja | Ja | Trigger-basiertes CDC + Sequenz-Checkpoints |
| PostgreSQL (wal2json) | Ja | Ja | Logische Replikation mit wal2json-Plugin |
| Neo4j | Ja | Ja | Zeitstempel-basiertes Tracking |
| JSONL-Dateien | Ja | Nicht verfügbar | Batch-Import aus JSON Lines |
| Apache Kafka | Ja | Ja | Consumer-Abonnements mit Deduplizierung |
Schnellstart
# Installieren von surreal-sync (Rust-Binärdatei)
cargo install surreal-sync
# Vollständige Synchronisation von PostgreSQL (Trigger-basiert)
surreal-sync from postgres trigger-full \
--connection-string "postgresql://user:pass@localhost/mydb" \
--surreal-endpoint "http://localhost:8000" \
--surreal-username root \
--surreal-password root \
--to-namespace prod \
--to-database main
# Inkrementelles CDC von PostgreSQL (wal2json)
surreal-sync from postgres wal2json \
--connection-string "postgresql://user:pass@localhost/mydb" \
--surreal-endpoint "http://localhost:8000" \
--surreal-username root \
--surreal-password root \
--to-namespace prod \
--to-database main
# Vollständige Synchronisation von MongoDB
surreal-sync from mongo full \
--connection-string "mongodb://localhost:27017/mydb" \
--surreal-endpoint "http://localhost:8000" \
--surreal-username root \
--surreal-password root \
--to-namespace prod \
--to-database main
# Batch-Import aus JSONL
surreal-sync from jsonl import \
--file data.jsonl \
--surreal-endpoint "http://localhost:8000" \
--surreal-username root \
--surreal-password root \
--to-namespace prod \
--to-database main
# Konsumieren von Kafka
surreal-sync from kafka consume \
--bootstrap-servers "localhost:9092" \
--topic my-events \
--surreal-endpoint "http://localhost:8000" \
--surreal-username root \
--surreal-password root \
--to-namespace prod \
--to-database main
CLI-Muster
surreal-sync from <QUELLE> <BEFEHL> \
--connection-string [VERBINDUNGSZEICHENKETTE] \
--surreal-endpoint [SURREAL-ENDPUNKT] \
--surreal-username [SURREAL-BENUTZERNAME] \
--surreal-password [SURREAL-PASSWORT] \
--to-namespace <NS> \
--to-database <DB>
Hauptfunktionen
- Automatische Schema-Inferenz und Erstellung von SurrealDB-Tabellen
- Mapping von Datensatz-IDs aus Quellprimärschlüsseln
- Beziehungsextraktion und Erstellung von Graph-Kanten
- Konfigurierbare Batch-Größen und Parallelität
- Wiederaufnehmbare Synchronisation mit Checkpoint-Tracking
- Deduplizierung für Kafka-Consumer
Vollständige Dokumentation
Siehe die Hauptregeldatei für vollständige Anleitungen:
- rules/surreal-sync.md – Quellkonfiguration, Schema-Mapping, CDC-Einrichtung, Konfliktlösung und Produktionsbereitstellung
- surrealdb/surreal-sync – Upstream-Repository