To move a database without downtime, keep the old database live as the source of truth. Copy the existing data, stream every new change to the new store and check that the two match until they agree. Then move reads and writes over in small steps you can undo. Retire the old database only after the new one has run alone, with no problems, for an agreed period.

Why do database migrations cause outages?

Most migration outages come from a "big-bang" cutover: stop writes, copy everything, switch the connection string and hope nothing was missed. That plan has four weak points:

  • Copy time grows with data volume. Stripe gives an example: at one second per object, moving 100 million objects one at a time would take over three years. Any plan that freezes writes for the length of a copy doesn't work at scale.
  • The switch can't be undone. Once writes land in the new store, the old one is out of date. Going back then means losing data.
  • Problems show up late. Wrong data types, missing rows and slow queries usually only appear under real traffic, after the switch.
  • The rollback was never tested. The team has a rollback plan on paper but has never run it.

AWS's own Database Migration Service guide says a plain full-load copy is a good choice only if you can afford an outage long enough to copy your data. Most businesses can't. Over half of respondents to the Uptime Institute's 2024 survey said their most recent serious outage cost more than $100,000. One in five said it cost more than $1 million.

The fix is to break one risky event into a series of small steps, each of which you can undo.

How do we copy and backfill data while the old system runs?

Take a consistent snapshot of the old database and bulk-load it into the new store. At the same time, capture every change made since the snapshot and replay those changes in order until the new store has caught up.

This is change data capture (CDC). AWS DMS describes a migration in three phases: a full load of existing data, applying the changes cached during that load, then ongoing replication. It collects changes from the database logs through the engine's own interface. Open-source tools such as Debezium work the same way: they take a snapshot first, then keep streaming changes from the log.

Steps that keep the backfill safe:

  1. Record the log position before the snapshot, so no change falls into the gap between the copy and the stream.
  2. Load in throttled batches, so the copy doesn't slow down the production database your users still depend on.
  3. Make every write idempotent. Insert-or-update by primary key, so a batch that runs twice gives the same result.
  4. Transform in the pipeline, not by hand. If the new schema splits or renames fields, keep that mapping in version-controlled code with tests.
  5. Track replication lag until it stays close to zero under normal traffic.

How existing data and live changes reach the new database while the app keeps writing to the old one
How existing data and live changes reach the new database while the app keeps writing to the old one

At this stage the application doesn't know a migration is happening. That is the point.

When do we use dual writes, and what are the risks?

Use dual writes only when CDC can't do the job. Two common cases are when the new data model can only be produced by application logic, or when you can't read the old database's change log. In every other case, CDC is the safer default.

Stripe's well-known four-step pattern:

  1. Write to both stores.
  2. Move reads to the new one.
  3. Move writes to the new one only.
  4. Remove the old data.

It works, but it puts the migration inside your application code. That brings risks:

  • Partial writes. Two separate stores can't commit together. One write succeeds, the other fails, and the data drifts apart without anyone noticing.
  • Ordering races. Two concurrent updates can reach the two stores in different orders.
  • More points of failure. Every request now depends on two databases, so an outage in the new store can hurt users.
  • Slower requests. Each request waits on a second write.

A Google Cloud community analysis puts it plainly: recovery is far simpler with CDC, and an outage in the target database doesn't affect clients.

If you do use dual writes, keep the old store as the single source of truth. Write to the new store asynchronously from a durable queue rather than inline. Log every failed write and put the whole thing behind a feature flag you can turn off in seconds.

Deciding between CDC replication and application dual writes for one migration
Deciding between CDC replication and application dual writes for one migration

How do we reconcile data between old and new stores?

Check the two stores against each other continuously, at more than one level of detail, and fix the cause of every unexplained difference. Never just patch the rows.

Check What it catches How often
Row counts per table or tenant Missing or duplicated batches Every few minutes
Checksums per key range Silent data drift in bulk Hourly or nightly
Field-level diffs on samples Transformation and type bugs Daily, plus after each deploy
Shadow reads Query differences under real traffic Continuously during the read stage

Shadow reads send a copy of production queries to the new store and compare the results. Users never see the new store's answer.

Every difference falls into one of three groups:

  • Replication lag: it clears on its own.
  • A mapping bug: fix the code, then re-backfill the affected key range.
  • A missed write: find the code path that skipped it.

Set the target as zero unexplained differences, not a percentage. In a ledger, an "acceptable" error rate means money that doesn't add up.

How do we move reads and writes in stages?

Move reads first, a slice at a time, behind a feature flag. Switch writes only when the new store is serving all reads correctly.

  1. Shadow reads. Compare results; users see only the old store.
  2. Read ramp. Serve real reads from the new store for one internal tenant, then 1%, 10%, 50% and 100% of traffic. Hold at each step until error rates and latency match the baseline.
  3. Keep each session on one store. While writes still go to the old store, replication lag can hide a user's own recent change. Route each user to one store, or keep recently written records on the old one.
  4. Switch writes. Make the new store the primary. Before this point, start replicating in reverse, from new to old, so the old store stays current.
  5. Soak. Run on the new primary through at least one full business cycle, including month-end jobs and batch runs.

The write switch is the only moment that needs tight coordination. Some engineering teams accept a pause of a few seconds while the last changes drain. If clients retry, users don't notice.

What is the rollback plan at each step?

Every stage needs a rollback that loses no data and a named trigger for when to use it. Write both down before the stage starts, and rehearse them on production-sized data.

Stage Rollback Trigger example
Backfill and CDC Drop the target and restart from a new snapshot Lag keeps growing, or a mapping bug
Dual writes Turn off the flag; the old store is still the source of truth Error rate or latency rises
Shadow reads Stop the shadow traffic Load on the new store hurts production
Read ramp Set the flag back to 0% Unexplained differences, or a latency target missed
Write switch Make the old store primary again; reverse replication kept it current Data errors after the switch
Retirement Restore from the archived final snapshot Audit or legal need for old records

The write switch is the step teams most often leave without a rollback. Reverse replication is what makes it undoable.

Lifecycle of a database cutover, with the rollback path out of each stage
Lifecycle of a database cutover, with the rollback path out of each stage

This is how our cloud migrations practice works: workloads move in phases, with a rollback plan for every step.

What should we measure before we retire the old database?

Retire the old database only when the new one has run as the sole primary through a full business cycle and all of the following hold:

  • Reconciliation: zero unexplained differences across all tables for the whole soak period.
  • Traffic: no reads or writes reaching the old database. Check its connection logs, not just your code, because old cron jobs and reporting tools often still connect.
  • Performance: p95/p99 latency (the slowest 5% and 1% of requests) and error rates at or better than the baseline you measured before the migration. If you don't track service-level objectives (SLOs) yet, set them up first; our observability and SRE work starts there.
  • Recovery: backups taken on the new store and a test restore completed.
  • Downstream consumers: dashboards, exports and data pipelines pointed at the new store and checked.
  • Sign-off: the business owner agrees the rollback window can close.

Then finish the job. Remove the dual-write code, the replication jobs and the old schema. This is the last step of what Martin Fowler calls Parallel Change, also known as expand and contract. If you skip it, the migration leaves behind code that nobody remembers how to run.

Conclusion

A database migration with no downtime isn't one clever trick. It's a series of small steps you can undo:

  1. Backfill with CDC.
  2. Use dual writes only when you have to.
  3. Reconcile until there are zero unexplained differences.
  4. Move reads, then writes, behind flags.
  5. Retire the old store only when the numbers say so.

Our Platform Modernization pods do this work: they move critical legacy systems onto modern, cloud-native platforms while the business keeps running. Migration code goes through the same three gates as every release we ship: tests, security checks and senior engineer review. Engagements start with a paid pilot: one pod, one outcome and success criteria agreed up front.

Talk to an engineering lead →

Frequently asked questions

Can a database migration really have zero downtime?

For reads, yes: a gradual read ramp is invisible to users. The write switch may need a pause of a few seconds while the last changes drain. If clients retry, users won't notice. The aim is no outage users can see, not literally zero milliseconds.

Is CDC or dual writes better for a database migration?

CDC is the safer default. It keeps the migration out of your application code, and an outage in the new database doesn't affect users. Use dual writes only when the new data model has to be produced by application logic or the old database's change log isn't available.

How long should the old database stay running after cutover?

At least one full business cycle on the new primary, including month-end jobs and batch runs. Keep reverse replication running for that whole period so you can still switch back. Retire the old database only once reconciliation, performance and traffic checks are all clean.

Does this approach work when moving from on-premises to the cloud, or between database engines?

Yes. The steps are the same: snapshot, stream changes, reconcile, ramp reads, switch writes, soak and retire. Moving between engines adds a step that translates types and schemas. Keep that translation in tested, version-controlled pipeline code, and expect more reconciliation work.

What usually goes wrong in a zero-downtime migration?

The usual failures are writes that silently fail during dual writes, replication lag that hides a user's own recent change, and a write switch with no reverse replication. Old cron jobs and reporting tools that still connect to the old database are another common surprise at retirement.

This article first appeared on Calidad Infotech.