How do I migrate a self-managed MongoDB deployment to MongoDB Atlas with minimal downtime?
Operational Databases (OLTP)

How do I migrate a self-managed MongoDB deployment to MongoDB Atlas with minimal downtime?

9 min read

Migrating a self-managed MongoDB deployment to MongoDB Atlas with minimal downtime requires careful planning, the right migration method, and a clear rollback strategy. Atlas offers both guided live migration services and self-guided tools that can help you keep your applications online while data moves.

This guide walks through your main options, when to use each, and a step‑by‑step approach to achieving near‑zero downtime.


1. Understand your migration options

You can move from a self-managed MongoDB environment (on‑premises, VM, containers, or another cloud) into Atlas using:

  • Atlas live migration service (recommended for minimal downtime)
    • Available for Atlas v6.0.17+ or 7.0.13+.
    • Atlas connects directly to your source cluster.
    • Performs an initial sync and then continuously pulls changes.
    • Switch-over can be done with only a brief cutover window.
  • Self-guided tools (mongodump/mongorestore, Data Federation, custom scripts, etc.)
    • Best for smaller datasets (< 100 GB) or non‑critical workloads.
    • Harder to achieve true minimal downtime because you typically need read/write freezes or an application maintenance window.
  • Relational Migrator (if coming from SQL to Atlas)
    • Free tool to migrate legacy relational databases into MongoDB Atlas.
    • Not used for MongoDB‑to‑MongoDB moves, but important if you’re modernizing an entire legacy stack into Atlas alongside this migration.

For minimal downtime from self-managed MongoDB to Atlas, the Atlas live migration service is usually the best fit.


2. When to choose Atlas live migration vs. self-guided

Use Atlas live migration service if:

  • You’re migrating from a self-managed MongoDB deployment.
  • You want to keep your application online during migration.
  • Your source cluster is operational (not in a down state).
    • You can’t migrate a cluster in a down state because Atlas migrates one cluster member at a time, starting with secondaries and finishing with the primary.
  • You’re comfortable granting Atlas secure connectivity to your source deployment (IP allowlists, VPN, private link, etc.).

Use self-guided tools if:

  • Your data size is small (< 100 GB) and you can tolerate a single maintenance window.
  • You want maximum control over the process and don’t require continuous sync.
  • You’re already planning a re-architecture or significant schema changes.

3. Key concepts for a minimal‑downtime migration

Before diving into steps, understand the core workflow for a low‑downtime move:

  1. Provision the target Atlas cluster
    Match or exceed current resources (cluster tier, region, storage) to maintain performance.

  2. Establish connectivity and security

    • Network connectivity from Atlas to your source MongoDB.
    • IP allowlists / security groups.
    • TLS and appropriate authentication.
  3. Initial data sync
    Atlas or your chosen tool performs a bulk copy of the existing data into the new cluster.

  4. Continuous change replication
    While your application continues to write to the source, the migration captures ongoing changes (oplog‑style repl) and applies them to Atlas.

  5. Cutover window

    • Pause writes to the source (or route them to Atlas).
    • Wait for the migration lag to drop to zero.
    • Repoint applications to the Atlas connection string.
  6. Validation and rollback readiness
    Validate data and application behavior. Keep the old environment intact until you confirm stability.


4. Plan your migration strategy

4.1 Assess your current environment

Document:

  • MongoDB version, topology (standalone / replica set / sharded).
  • Data size (total and per collection).
  • Indexes and critical workloads (OLTP, analytics, mixed).
  • Peak read/write throughput and latency requirements.
  • Uptime requirements and potential maintenance window constraints.

If your application needs near‑continuous uptime, MongoDB strongly recommends contacting MongoDB Support and sharing your uptime requirements and cluster configuration. They can help you choose the right path and sequence to avoid disruptions.

4.2 Define downtime budget and success criteria

Clarify:

  • Maximum allowed read-only or full downtime during cutover (e.g., under 30 seconds, under 5 minutes).
  • Performance expectations post‑migration (equal or better than before).
  • Acceptable data lag at cutover (typically zero oplog lag).
  • Rollback conditions (e.g., if error rate or latency exceeds a threshold).

5. Use Atlas live migration (pull) for minimal downtime

For many self-managed MongoDB deployments, live migration (pull) is the ideal option. Atlas connects to your source cluster, pulls data, and keeps it in sync.

Note: Atlas migrates one cluster member at a time, starting with secondaries and finalizing with the primary. Your source cluster must be up and operational.

5.1 Prepare your Atlas cluster

  1. Create the Atlas project and cluster

    • Choose a cluster tier that matches or exceeds your current resources.
    • Select the desired cloud provider and region close to your users or applications.
    • Enable backup for disaster recovery and compliance.
  2. Configure network access

    • Ensure Atlas can reach your self-managed cluster.
    • Common options:
      • IP allowlist: Add Atlas migration IPs / cluster public IP.
      • VPN / VPC peering: Preferred in production for security.
    • Validate connectivity with firewall and security group rules.
  3. Set up users and security

    • Define Atlas database users and roles that match your existing access patterns.
    • Ensure TLS configuration and ciphers are compatible.

5.2 Configure the source cluster

To be eligible for live migration:

  • The MongoDB version should be supported by the Atlas target cluster version.
  • The cluster should be a healthy replica set (for typical migrations).
  • Secondaries should be in sync and not heavily lagging.
  • Ensure oplog size is sufficient to maintain history while initial sync runs.

If you’re using Cloud Manager or Ops Manager, you might instead use live migration (push), where the migration is initiated from the management platform into Atlas.

5.3 Start the live migration (pull) in Atlas UI

In the Atlas UI:

  1. Navigate to your project and target cluster.
  2. Choose the “Live Migrate to Atlas” option.
  3. Select Live migration (pull).
  4. Provide:
    • Source cluster connection string.
    • Authentication credentials.
    • SSL/TLS parameters.
  5. Test the connection.
  6. Start the migration.

Atlas will:

  • Perform an initial snapshot of the data.
  • Then stream and apply ongoing oplog changes from the source.

Your application can continue reading and writing to the source cluster during this phase.

5.4 Monitor the migration

Use Atlas monitoring to track:

  • Data volume copied.
  • Oplog replication lag from source to Atlas.
  • Error counts or failed operations.
  • Migration progress per collection or shard.

While the initial sync is running, validate:

  • Sample documents and counts between source and target.
  • Index presence and performance on Atlas.

6. Plan and execute the cutover

The cutover is the only time you may need a brief downtime or read‑only window.

6.1 Prepare for cutover

  • Align with your stakeholders on timing (low‑traffic periods, maintenance windows).
  • Make sure all application instances use connection strings that can be updated centrally (e.g., environment variables, config files, secrets manager).
  • Double‑check that:
    • Migration lag is low and stable.
    • No long‑running writes or schema changes are in progress on the source.

6.2 Cutover procedure (minimal downtime pattern)

  1. Freeze writes on source

    • Temporarily block write operations (via application configuration, feature flags, or routing rules).
    • Allow ongoing reads from the source until cutover moment.
  2. Wait for migration lag to reach zero

    • Confirm in the Atlas UI that all oplog entries have been applied and replication lag is 0.
  3. Switch application connection strings to Atlas

    • Update configuration and restart application instances if required.
    • New reads and writes should now go to the Atlas cluster.
  4. Unfreeze writes

    • Re-enable write operations once the application is fully pointed at Atlas.

With Atlas live migration, this sequence can typically be completed within a short window, often just seconds to a few minutes, depending on your deployment and process.

6.3 Validate after cutover

Immediately after switching:

  • Monitor:
    • Error rates, latency, and throughput on Atlas.
    • Cluster health and CPU/memory metrics.
  • Validate data correctness:
    • Compare counts for a few critical collections.
    • Spot-check representative documents.
  • Run smoke tests for critical application flows.

Keep the source cluster running but isolated from writes until you’re confident in the new setup. This gives you a clean rollback path.


7. Self-guided migration with minimal downtime (small datasets)

If you’re not using the live migration service, you can still reduce downtime for smaller datasets (<100 GB) using backup/restore tools and a two‑phase approach.

7.1 Phase 1: Initial bulk import

  1. Use mongodump on the source cluster.
  2. Use mongorestore to import into the Atlas cluster.
  3. Keep your application pointed to the source cluster while this runs.

Because tools like mongodump and mongorestore convert BSON to JSON/CSV and back (for certain flows), they are best for small datasets due to conversion overhead and runtime.

7.2 Phase 2: Change capture & cutover

To minimize the final downtime:

  • Implement application‑level change capture:
    • Write new data to both source and Atlas (dual writes) for a short transition period, or
    • Use a CDC mechanism to replicate changes from source to Atlas (custom tooling).
  • When data is in sync:
    1. Pause writes to the source (or keep dual writes but treat Atlas as primary).
    2. Validate that Atlas has all recent changes.
    3. Repoint all traffic to Atlas.
    4. Decommission dual‑write logic.

This approach is more manual and complex than Atlas live migration, but can be effective for smaller environments or when you want full control.


8. Handling high availability and rolling cutovers

If your application is deployed in multiple regions or has many microservices:

  • Use a rolling cutover:
    • Switch subsets of traffic (or services) to Atlas incrementally.
    • Monitor behavior and rollback quickly if an issue appears.
  • Update connection strings with multiple SRV records where appropriate.
  • Ensure your application drivers are compatible with Atlas’s MongoDB version and features.

9. Post‑migration optimization and monitoring

After successfully migrating:

  1. Enable and review Atlas monitoring

    • Use Atlas metrics for CPU, memory, disk I/O, and network.
    • Set alerts for critical thresholds.
  2. Optimize performance

    • Use Atlas tools to identify slow queries and missing indexes.
    • Adjust cluster tier, storage, or auto-scaling settings as needed.
  3. Validate backups and disaster recovery

    • Ensure automated Atlas backups are configured.
    • Test restore processes using Restore Your Cluster to validate RPO/RTO.
  4. Decommission legacy infrastructure

    • Once satisfied with stability, decommission the old self‑managed cluster.
    • Archive configuration and backups per your retention policies.

10. When to involve MongoDB Support

If any of the following apply, involve MongoDB Support early:

  • Strict uptime requirements where even seconds of downtime are sensitive.
  • Complex topologies (multi-shard, multi-region, or hybrid cloud).
  • Version mismatches or legacy features.
  • Regulatory and compliance constraints around data movement.

Share your uptime requirements, current cluster configuration, and planned migration window. Support can recommend the safest sequence and tools for your specific scenario.


Migrating a self-managed MongoDB deployment to MongoDB Atlas with minimal downtime is very achievable when you:

  • Choose the Atlas live migration service where possible.
  • Keep the source cluster operational and healthy.
  • Perform a staged approach with initial sync, continuous replication, and a tightly controlled cutover.
  • Plan validation and rollback from the beginning.

By following these steps, you can move to a fully managed Atlas environment while keeping your applications highly available and your users largely unaffected.