Database migration routes and downtime: offline, minimal or near-zero

Every database migration ends with a switch, and the question is how long the application is unavailable during that switch. This guide explains the three classes of downtime, how to choose between them, what makes online routes fail, and which routes exist per database engine and target.

Three classes of downtime

The switch is the moment the application stops using the old database and starts using the new one. What differs between routes is how much of the copying happens before that moment. Three classes cover almost every case:

  • Offline (hours): a maintenance window, for example a night or a weekend. The application is stopped, the database is copied in full (backup and restore, dump and load, export and import), checked, and the application is pointed to the new database. This is the simplest and cheapest route and the easiest to roll back, but the downtime grows with the size of the database.
  • Minimal downtime (minutes): the bulk of the data is copied while the old database stays in use, then the changes made since then are applied (log backups, log shipping, replication, change data capture). At the switch you stop writes, let the last changes arrive and reconnect the application.
  • Near-zero downtime (seconds): continuous replication keeps the new database in sync until the switch, and the switch itself is a connection change, sometimes with a few seconds of read-only. This needs the most preparation: a primary key on every table, a setup that supports replication and an application that reconnects by itself. It also costs more in tools, licences and testing.

The same tool can belong to two classes. Log shipping or a replication stream gives minutes of downtime when the switch is done by hand, and seconds when it is scripted and rehearsed. The class is decided by the switch, not by the tool.

How to choose

Start from the business, not from the tools. These questions usually settle the choice:

  • What does an hour of downtime really cost? Count lost sales, staff who cannot work and contractual penalties for a realistic moment, not the worst case. If a Sunday night costs little, an offline route is hard to beat: a near-zero route easily adds several days of preparation and testing, plus tools or licences.
  • How long does a full copy take? Measure it (see the next section). If a full copy, the checks and a margin for a second attempt fit in the window you can get, offline is enough.
  • How much changes per hour? The change rate (log or binlog volume per hour) decides whether a replication stream can keep up and how long the final catch-up takes. A database that writes 50 GB of log per hour needs a different setup than one that writes 500 MB.
  • How do you go back? After an offline switch the old database is unchanged. After an online switch the new database has taken writes, and going back means losing them or replicating them back. Decide this before you choose the route.
  • Can you rehearse? Every route that is more than a plain backup and restore needs at least one full rehearsal on a copy, with the switch timed. Without time or an environment for a rehearsal, the extra complexity of an online route is a risk in itself.

Database size and copy time

For an offline route the downtime is roughly the time to copy the data, plus the time to build indexes and constraints, plus the checks, plus reconnecting the application. The copy speed depends on the method, the disks and the network, so measure it on a copy of your own database. Some rules of thumb:

  • Native physical backups (SQL Server backup and restore, RMAN, pg_basebackup) copy data pages and are usually much faster than logical dumps, which read every row and rebuild every index on the target.
  • With logical dumps and loads (pg_dump, mysqldump, Data Pump, mongodump), building indexes and checking foreign keys after the load can take as long as loading the data. Parallel tools (pg_restore -j, MySQL Shell, mydumper, Data Pump with PARALLEL) help a lot on servers with several cores.
  • Compression reduces what crosses the network. A compressed backup is often several times smaller than the database, but that depends on the data: compressed or encrypted data hardly shrinks.
  • For a move to the cloud the network is often the bottleneck. 1 Gbit/s is 125 MB/s, so in theory at most 450 GB per hour; with protocol overhead and real disks, 250 to 350 GB per hour is a more realistic figure, and VPN tunnels are often slower.
LinkTheoretical maximumRealistic1 TB takes about
100 Mbit/s45 GB per hour25–35 GB per hour30–40 hours
1 Gbit/s450 GB per hour250–350 GB per hour3–4 hours
10 Gbit/s4.5 TB per hour1–3 TB per hour (disks often limit)20–60 minutes

If the copy alone does not fit in the window, there are three options: copy the bulk in advance and only the changes during the window (a minimal-downtime route), ship the data on a physical device where the cloud provider offers one and catch up with log backups or replication, or make the database smaller first by archiving old data.

What makes online routes fail

Online routes copy changes row by row while the application keeps working. That only works when every change can be identified and replayed on the target. The usual problems:

  • Tables without a primary key: replication cannot tell which row an update or delete belongs to. PostgreSQL logical replication refuses updates and deletes on such tables unless a replica identity is set, SQL Server transactional replication only publishes tables with a primary key, and MySQL row-based replication may scan the whole table for every change.
  • Large objects: LOB columns (varchar(max), CLOB, BLOB, bytea) are slow or limited in CDC tools; AWS DMS, for example, has separate LOB modes with size limits. PostgreSQL large objects (pg_largeobject) are not replicated at all by logical replication.
  • Unlogged tables: PostgreSQL unlogged tables do not write to the log, so log-based replication does not see them.
  • DDL during the migration: most replication methods do not carry schema changes, or only some of them. Freeze schema changes and releases until after the switch.
  • Sequences and identity values: in most tools, replicated inserts do not advance the counters on the target. Set them to the source's values plus a margin at the switch, or the first new row fails on a duplicate key.
  • Triggers firing twice: a trigger that writes an audit row fires on the source and again on the target when the replicated row arrives. Disable such triggers on the target during replication, or mark them as not for replication where the engine supports that.
  • Foreign keys and triggers during the initial load: tables are loaded in parallel and in no particular order, so foreign keys and triggers are usually disabled during the load and enabled afterwards, with a check.
  • Time to build indexes: on large tables, building indexes after the load can take hours, and the backlog of changes grows in the meantime.
  • Collation and encoding differences: another collation or character set changes sort order, uniqueness and comparisons, so a row that is unique on the source can collide on the target. Check them before the first test load.

SQL Server to SQL Server

For a move to a newer SQL Server, a new server or a managed service in the cloud. Most routes need a source version that the target still accepts, and the online routes have their own minimum versions and editions: check them per route for your version.

TargetOfflineMinimal (minutes)Near-zero (seconds)
SQL Server on a new server or VMBackup and restoreFull, differential and log backups; log shippingAlways On availability group or distributed availability group
Azure SQL Managed InstanceNative backup to URL, then RESTORE FROM URLLog Replay Service; Azure DMS (online)Managed Instance link (distributed availability group)
Azure SQL Database.bacpac (SqlPackage); Azure DMS (offline)Transactional replication (Azure SQL Database as subscriber)—
Amazon RDS for SQL ServerNative backup and restore via S3Full and log backups via S3; AWS DMS (CDC)—
Cloud SQL for SQL Server.bak import from Cloud StorageDatabase Migration Service (full and log backups)Database Migration Service with a distributed availability group

Log Replay Service and Azure DMS in online mode restore full, differential and log backups from Azure Blob Storage on the Managed Instance and switch over after a last log backup. The Managed Instance link keeps a Managed Instance in sync through a distributed availability group and needs a supported SQL Server version and update level at the source.

Azure SQL Database accepts no native backups. Data goes in through a .bacpac, Azure DMS in offline mode, or transactional replication with Azure SQL Database as a push subscriber, which keeps the switch to minutes but needs a primary key on every published table.

AWS DMS reads changes from SQL Server through MS-CDC or MS-Replication, which you have to enable on the source. It copies tables and primary keys, not secondary indexes or code such as stored procedures and triggers: create those separately. On Cloud SQL, Database Migration Service replays full and log backups from Cloud Storage; Google also documents a direct route with a distributed availability group for some source editions.

In all these routes, logins, SQL Server Agent jobs, linked servers and credentials live outside the database: script them and recreate them before the switch.

PostgreSQL to PostgreSQL

For a major version upgrade, a move to another server or a move to a managed service. Logical replication works between different major versions, which makes it the basis of most online routes. Whether an online route gives minutes or seconds depends on how the switch is done.

TargetOfflineOnline (minutes or seconds)
Own server or VMpg_dump + pg_restore -j; pg_upgrade (with --link: minutes)Logical replication; pglogical; AWS DMS
Amazon RDS or Aurorapg_dump + pg_restore; in-place major version upgradeBlue/green deployment; AWS DMS; logical replication
Azure Database for PostgreSQLpg_dump + pg_restore; migration service (offline); in-place major version upgradeMigration service (online); logical replication
Cloud SQL or AlloyDBpg_dump + pg_restore; in-place major version upgradeDatabase Migration Service (continuous); logical replication

Native logical replication (publication and subscription) needs wal_level = logical on the source and a primary key or a REPLICA IDENTITY on every table that gets updates or deletes; REPLICA IDENTITY FULL works but is slow on large tables. It does not replicate DDL, large objects or unlogged tables. Sequences are only synchronised from PostgreSQL 19 on (ALTER SUBSCRIPTION ... REFRESH SEQUENCES, with a publisher on version 19 or later); with an older source, set them at the switch with setval.

For pg_dump, the directory format (-Fd) allows both the dump and the restore to run in parallel with -j. pg_upgrade --link upgrades in minutes whatever the size, because it reuses the data files, but once the new cluster has started the old one can no longer be used safely: the way back is a restore. Take a backup first, or upgrade a copy.

Blue/green deployments on Amazon RDS and Aurora create a copy (green) that is kept in sync by replication; for a major version upgrade that is logical replication, with the same limits. AWS states that the switchover typically takes under a minute. The migration service of Azure Database for PostgreSQL has an online mode that keeps the target in sync until you start the cutover.

On large databases the initial copy of logical replication runs table by table and can take a long time. Tools that copy in parallel, such as pgcopydb (used by the Azure migration service), shorten it.

MySQL and MariaDB

MySQL and MariaDB both write a binary log (binlog), and almost every online route reads it. The offline routes are a dump and load, or an in-place upgrade.

TargetOfflineOnline (minutes or seconds)
Own server or VMmysqldump or mariadb-dump; MySQL Shell dump and load; mydumper / myloader; in-place upgradeBinlog replication to the new server (GTIDs help)
Amazon RDS or AuroraMySQL Shell, mydumper or mysqldump; in-place major version upgradeBinlog replication into RDS; AWS DMS; blue/green deployment
Azure Database for MySQLDump and load; in-place major version upgradeData-in replication (binlog)
Cloud SQL for MySQLDump and importDatabase Migration Service (continuous); replication from an external server

An in-place upgrade goes one LTS series at a time: 5.7 → 8.0 → 8.4 → 9.7. MySQL cannot be downgraded in place, so the way back is a restore of a backup taken just before. Replicating to a new server that already runs the new version avoids that, within the version combinations that MySQL supports for replication: the old server remains the way back.

AWS DMS and most CDC tools need binlog_format=ROW (and binlog_row_image=FULL) on the source, and a binlog retention long enough to cover the full load plus a margin. GTIDs make it easier to restart replication and to switch at the right position.

Tables without a primary key replicate badly with row-based replication, because each change on the replica can mean a full table scan. Add a primary key, or at least a unique index, before the migration.

MySQL and MariaDB have grown apart (GTID format, JSON, system tables). Replication between the two only works in limited version combinations; for a move from one to the other, a dump and load is usually the safer route.

Oracle to Oracle

For a move to new hardware, a newer version, Exadata in a public cloud (Oracle Database@AWS, @Azure and @Google Cloud, or OCI) or Amazon RDS for Oracle. Oracle has the widest choice of physical and logical routes; some of them need extra licences.

TargetOfflineMinimal (minutes)Near-zero (seconds)
Own server or VMData Pump (expdp / impdp); RMAN backup and restore; transportable tablespacesStandby from RMAN incremental backups + Data Guard switchover; transportable tablespaces with incremental backupsGoldenGate
Exadata in OCI, AWS, Azure or Google CloudData Pump; RMANZero Downtime Migration, physical online (Data Guard)Zero Downtime Migration, logical online (GoldenGate)
Amazon RDS for OracleData Pump (via S3 or a database link)AWS DMS (full load + CDC)GoldenGate

Data Guard and RMAN routes copy the database physically: the standby runs the same version as the source, so a version upgrade happens after the switch, and a move to another platform needs a conversion step. A Data Guard switchover usually takes a minute or a few minutes; with an application that reconnects by itself, users barely notice it. Transportable tablespaces with incremental backups reduce the window to the last incremental backup plus the export of the metadata.

Zero Downtime Migration (ZDM) is Oracle's tool that automates these routes to Exadata and Autonomous Database targets: its physical online mode uses Data Guard, its logical online mode Data Pump plus GoldenGate. Check its list of supported sources and targets for your version. GoldenGate needs its own licence or cloud service.

Amazon RDS for Oracle does not support configuring Data Guard from your own server, so the usual routes there are Data Pump for offline and AWS DMS or GoldenGate for online. AWS DMS needs supplemental logging on the source and handles LOB columns in separate, slower modes.

MongoDB to MongoDB, Atlas, DocumentDB or Cosmos DB

The online routes for MongoDB read the oplog, which only exists on a replica set or a sharded cluster.

TargetOfflineOnline (minutes or seconds)
Own replica set or VMmongodump / mongorestoreNew servers as replica set members, then step down the old primary; mongosync
MongoDB Atlasmongodump / mongorestoreAtlas Live Migration; mongosync
Amazon DocumentDBmongodump / mongorestoreAWS DMS (full load + CDC)
Azure Cosmos DB for MongoDBmongodump / mongorestoreRU: Azure DMS (online); vCore: Microsoft's migration extension

mongosync and Atlas Live Migration need a replica set or a sharded cluster as source. A standalone server must first be converted to a single-node replica set, which needs a restart with a replica set name. mongosync supports specific version combinations (current releases: source 5.0 to 8.0, destination 6.0 or later); check the matrix for your release.

Adding new members to the existing replica set is the classic near-zero route between your own servers: the new members sync, you make one of them primary and remove the old ones. Drivers that use a replica set connection string follow the new primary; update the host list afterwards.

Amazon DocumentDB and Azure Cosmos DB for MongoDB are compatible with the MongoDB API, not identical to MongoDB: some operators, index types and aggregation stages are missing. For Cosmos DB, Azure DMS supports online migration to the RU-based service (Premium tier); for the vCore-based service Microsoft points to its own migration extension. Test the application against the target before you plan the switch.

DynamoDB to another account, region or database

DynamoDB has no dump in the classic sense. The building blocks are the export to S3, the import from S3, DynamoDB Streams and global tables.

TargetOfflineOnline (minutes or seconds)
Another regionExport to S3 + import from S3 into a new tableGlobal tables: add a replica in the new region, then switch the application
Another accountExport to S3 (bucket in the other account) + import from S3Multi-account global tables; or export plus DynamoDB Streams and Lambda to catch up
Another databaseExport to S3 or AWS Glue, then load into the targetDynamoDB Streams to a process that writes to the target

Export to S3 needs point-in-time recovery on the table, exports the table as it was at one moment and uses no read capacity. Import from S3 always creates a new table; it cannot load into an existing one.

To catch up after an export, enable DynamoDB Streams before the export time and replay the changes made after that moment on the new table. Stream records are kept for 24 hours, so the catch-up has to start within that window, and the writes must be idempotent because a change can be delivered more than once.

Global tables across accounts have been available since February 2026: each replica sits in its own account, replication is eventually consistent, and you start from a table in a single region. An existing global table within one account cannot be converted.

To another engine: PostgreSQL, Babelfish or MySQL

When the engine changes, the schema and the code are converted first and only then is the data moved. The conversion is usually the bigger job: data types, stored procedures, functions and triggers have to be rewritten and tested. The downtime then depends on whether a change data capture (CDC) tool can carry the changes to the target while the application still runs on the source.

RouteSchema and codeOffline dataOnline (CDC)
SQL Server → PostgreSQLAWS DMS Schema Conversion; manual workpgloader; Azure Data FactoryAWS DMS; Debezium
SQL Server → BabelfishBabelfish Compass, then the T-SQL scriptAWS DMS (full load); bcpAWS DMS
SQL Server → MySQLAWS DMS Schema Conversion; MySQL WorkbenchAzure Data Factory; MySQL WorkbenchAWS DMS; Debezium
Oracle → PostgreSQLora2pg; AWS DMS Schema Conversionora2pgAWS DMS; GoldenGate; Debezium; Google Database Migration Service

Debezium reads the source log and writes the changes to Kafka; a sink connector or your own process then writes them to the target, so it is a building block rather than a ready-made migration tool. AWS DMS combines the full load and CDC in one task, but copies tables, not code, and has its own limits for LOBs and data types.

After a switch to another engine, going back is harder than within one engine: the old database only stays current if you replicate the changes back, which needs a second CDC pipeline in the other direction. Many projects therefore accept an offline or short minimal-downtime switch and put the effort into testing beforehand.

Switch-over checklist

Whatever the route, the switch follows the same steps. Write them down as a script with names and times, and run it at least once in a rehearsal.

  • Freeze DDL and releases from the start of replication until after the switch.
  • Rehearse with timing: run the complete switch on a copy, measure every step and plan the window from those times, with a margin.
  • Logins, jobs and permissions are in place on the target before the switch.
  • Compare row counts and checksums per table before and after the switch, and run a few business checks (totals, last order, open invoices).
  • Stop writes on the source (application stopped or database read-only) and confirm that the replication lag is zero.
  • Sync sequences and identity values to the current values of the source, with a margin.
  • Re-point connection strings or DNS: a DNS name or listener with a short TTL makes the switch one change instead of many configuration files. Do not forget jobs, reports and interfaces that connect directly.
  • Rollback criteria and deadline: decide in advance which problems lead to a rollback and until what time a rollback is still possible.
  • Monitor after the switch: errors, slow queries, connections and any replication back to the old system, at least during the first business day.

The way back

A rollback plan is part of the route, not an afterthought. There are three common forms:

  • Old system untouched: after an offline switch the old database still has the state of the moment of the switch. Going back means reconnecting the application, as long as no important data has been written to the new database or it can be entered again.
  • Old system kept read-only: useful for checks and reports, but writes made after the switch exist only in the new system.
  • Reverse replication: after the switch, changes on the new database are replicated back to the old one (Data Guard after a switchover, GoldenGate, logical replication or a CDC tool in the other direction). This keeps going back possible for days, at the cost of extra setup and testing.

Set a deadline: after a certain point, for example the end of the first business day, going back costs more than fixing forward. In-place upgrades (pg_upgrade --link, an in-place MySQL upgrade) have no quick way back at all: there the backup taken just before is the rollback plan, and its restore time belongs in the planning.

How the free scan helps

The MigrateMyDatabase scan runs a read-only script on your database that collects the structure, not the data. You paste the result in the page and choose a target and the downtime you can accept. The analysis runs in your browser and shows which routes fit that downtime for the chosen target, and the points in your database that make online routes harder: tables without a primary key, large objects, unlogged tables. Nothing is uploaded, and the page never connects to your database.

Questions

What is the difference between minimal and near-zero downtime?

In both cases the bulk of the data is copied while the old database stays in use. With minimal downtime the switch takes minutes: writes stop, the last changes are applied and the application is reconnected. With near-zero downtime, replication runs continuously and the switch is a connection change of seconds, which needs more preparation, more testing and often licences.

How long does an offline migration of 1 TB take?

That depends mostly on the method and the network. A native backup and restore on a fast local network can take well under an hour; a logical dump and load of the same database, with index builds, often takes several hours; over a 1 Gbit/s link to the cloud the transfer alone takes about 3 to 4 hours. Measure it on a copy.

Can every database be migrated with near-zero downtime?

Not without preparation. Tables without a primary key, large objects, unlogged tables and frequent schema changes make online routes harder or impossible for the tables concerned. Some targets also have no near-zero route, for example Azure SQL Database or Amazon RDS for SQL Server, where the shortest switch takes minutes.

Is an offline migration old-fashioned?

No. For most databases up to a few hundred gigabytes, with a night or a weekend available, it is the simplest, cheapest and safest route, with the easiest rollback. Online routes pay off when downtime is expensive or the database is too large to copy within the window.

What happens to sequences and identity columns?

Most replication tools copy the rows but do not advance the counters on the target. At the switch, set each sequence or identity to the current value of the source plus a margin, or the first new row fails on a duplicate key. PostgreSQL 19 can synchronise sequences through logical replication when the publisher also runs version 19 or later.

How do I go back if the new database has problems?

Decide that before the switch: either the old database stays untouched and you accept losing the writes made after the switch, or you replicate the changes back to it. Set a deadline after which you fix problems on the new database instead of going back.

Read next

Choose your target and the downtime you can accept, and see which routes fit and which tables stand in the way: run the free read-only scan. Nothing leaves your browser.

Start the free scan