← Lessons

quiz vs the machine

Gold1400

Databases

Database Replication For Migration

Using a replica to seed and continuously catch up the new database.

5 min read · core · beat Gold to climb

Migrating By Replicating

A clean way to move to a new database is to make the target a replica of the source. The source streams its ongoing changes into the target until both are in sync, then you switch traffic over.

Two Phases

  • Initial snapshot: copy the existing data in bulk to seed the target.
  • Ongoing replication: stream changes committed after the snapshot so the target keeps catching up.

Tools like AWS DMS or native logical replication combine these so the target converges to within seconds of the source.

Watching The Lag

The key metric is replication lag, how far behind the target is. Before cutover you wait for lag to fall near zero. A small lag means a brief, controlled switch rather than a long outage. Heterogeneous migrations, where source and target are different engines, also need type mapping so each source column lands in a compatible target type.

Key idea

Replication based migration seeds the target with a snapshot then streams ongoing changes until replication lag nears zero, enabling a brief controlled cutover.

Check yourself

Answer to earn rating on the learn ladder.

1. What are the two phases of replication based migration?

2. Why wait for replication lag to near zero before cutover?

3. What extra concern arises in a heterogeneous migration?