/ Migrations / Live sync (CDC)
Docs/Migrations/Live sync (CDC)

Live sync (CDC)

Live sync copies existing data, then streams every subsequent change from the source to the target — so the two stay in step while your application keeps writing.

How it works

  • Copy. Existing data is copied exactly like a one-time migration.
  • Stream. NoSQLSync then reads the source's change feed. Inserts and updates become upserts on the target's primary key; deletes become deletes.
  • Checkpoint. After each successful write the feed position is saved, so a restart resumes where it stopped instead of replaying everything.

For MongoDB, NoSQLSync records the cluster time before the copy starts and streams from that point, so writes made during the copy are never missed. For the other sources, streaming starts from the feed's current position — if the source takes heavy writes during the initial copy, run a validation once it settles.

Supported sources

SourceMechanismRequirementsNotes
MongoDBChange streamsReplica set or sharded cluster (any Atlas tier)Resumes from a saved token.
DynamoDBDynamoDB StreamsStream enabled with NEW_AND_OLD_IMAGESResumes per shard.
Cosmos DBChange feedNoSQL (Core) APIDeletes are not captured.
FirestoreSnapshot listenersService accountAfter a restart, resumes from current state.

Cassandra, Couchbase and SQL sources support one-time migrations only.

Creating a live sync

In the dashboard, open Live Sync and click Create channel, or choose the Live sync mode in the New migration wizard. Over the API, create a migration with "mode": "cdc":

Create a live sync
curl -X POST https://nosqlsync.com/engine/migrations \
  -H "Authorization: Bearer $NOSQLSYNC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "orders → postgres",
    "sourceConnectionId": "…",
    "targetConnectionId": "…",
    "sourceDatabase": "shop",
    "sourceCollection": "orders",
    "targetTable": "orders",
    "mode": "cdc"
  }'

Each running live sync counts as one channel against your plan. The Free plan doesn't include live sync.

Monitoring lag

Lag is the time between a change happening at the source and landing in the target. It is shown on the migration page and in Live Sync, and is available from GET /migrations/:id/metrics.

Each live sync has a lag alert threshold — 60 seconds by default. When lag exceeds it, NoSQLSync sends a cdc.lag_exceeded webhook, and a cdc.lag_recovered when it drops back. Change the threshold with:

PATCH /migrations/:id
{ "lagAlertThresholdMs": 300000 }   // 1s – 24h, or null to disable

Pausing and restarting

Pausing keeps the saved position. On resume, the changes made in the meantime are applied — provided the source still has them.

!
Change-feed retention

Sources only keep changes for a limited time — the MongoDB oplog window, or 24 hours for DynamoDB Streams. If a live sync is paused or down longer than that, changes from the gap can't be replayed. For MongoDB the migration fails with a history lost error; starting it again re-copies the collection from scratch and then resumes streaming.

Sizing the MongoDB oplog

On Atlas, check Metrics → Oplog GB/Hour and the replication oplog window. Aim for a window of at least 24 hours so maintenance or a paused sync can catch up.

Schema changes while streaming

When a MongoDB live sync sees a field that isn't in the mapping, the migration's drift policy decides what happens. See Schema drift.

Moving production traffic

Live sync is the foundation for a zero-downtime move. When you're ready to switch, read Cutover.