Skip to content

CDC: MongoDB to PostgreSQL | Real-Time Replication Guide

Real-time Change Data Capture from MongoDB to PostgreSQL with exactly-once delivery, order-token guards, and tombstone anti-resurrect protection.

Source: MongoDB. Destination: PostgreSQL.

CDC apply: Staging table + INSERT ON CONFLICT.

Sample config

yaml
skippr:
  workspace: cdc_mongodb_to_postgres
pipelines:
  cdc_mongodb_to_postgres:
    data_source: data_sources.source
    data_sink: data_sinks.warehouse
    cdc:
      default:
        business_key_columns:
          - id
data_sources:
  source:
    Mongodb:
      connection_string: "mongodb://user:${MONGO_PASSWORD}@host:27017/mydb"
      database: mydb
      collection: events
      cdc_mode: snapshot_then_cdc
data_sinks:
  warehouse:
    Postgres:
      host: localhost
      port: 5432
      user: ${POSTGRES_USER}
      password: ${POSTGRES_PASSWORD}
      database: analytics
      schema: public

Environment

bash
export POSTGRES_HOST="localhost"
export POSTGRES_USER="myuser"
export POSTGRES_PASSWORD="mypassword"

Source connector: mongodb. Destination connector: postgres-warehouse.

See CDC overview.