All Products
Search
Document Center

ApsaraDB for MongoDB:Migrate data from an ECS-hosted self-managed MongoDB database that uses the standalone or replica set architecture to ApsaraDB for MongoDB

Last Updated:Mar 28, 2026

Use Data Transmission Service (DTS) to migrate a self-managed MongoDB database hosted on Elastic Compute Service (ECS) — standalone or replica set architecture — to ApsaraDB for MongoDB. DTS supports both full and incremental data migration, keeping your workloads running throughout the migration.

Prerequisites

Before you begin, make sure you have:

  • A self-managed MongoDB database running MongoDB 3.0 or later

  • An ApsaraDB for MongoDB instance with more storage space than the source database size

  • (If source and destination versions or storage engines differ) Confirmed no compatibility issues — see MongoDB versions and storage engines for supported combinations

Billing

Migration typeInstance configurationsInternet traffic
Full data migrationFreeFree
Incremental data migrationCharged. See DTS pricing.Free

Migration types

Full data migration copies all existing data from the source to the destination. Migration is supported at the database, collection, and index levels.

Note

Do not write to the source database during a full-only migration. Writes during this window can cause data inconsistency.

Incremental data migration continuously synchronizes changes to the destination after the full migration completes. The following operations are synchronized:

  • Create and delete operations on databases, collections, and indexes

  • Create, delete, and update operations on documents

To migrate without business interruptions, use both full and incremental data migration together.

Required permissions

Set up database accounts with the following permissions before you configure the migration task.

DatabaseFull data migrationIncremental data migration
Self-managed MongoDB on ECSRead on the source databaseRead on the source database, the admin database, and the local database
Destination ApsaraDB for MongoDBRead and write on the destination databaseRead and write on the destination database

To create accounts and grant permissions, see:

Usage notes

  • Schedule the migration during off-peak hours to minimize impact on running workloads.

  • Do not migrate data from the config database. It is an internal MongoDB database.

Preparations

Replica set architecture: No preparation needed. Skip this section.

Standalone architecture with incremental migration: Enable oplog on the source database before creating the migration task. For instructions, see Migrate a self-managed standalone MongoDB database to Alibaba Cloud by using DTS.

Create and run the migration task

Step 1: Open the previous-version DTS console

  1. Log on to the DTS console.

  2. Click the 返回DTS旧版控制台 icon in the lower-right corner to switch to the previous version of the console.

  3. In the left-side navigation pane, click Data Migration.

  4. In the Migration Tasks section, select the region where the ApsaraDB for MongoDB instance is deployed.

  5. In the upper-right corner, click Create Migration Task.

Step 2: Configure source and destination databases

Task name

DTS generates a name automatically. Specify a descriptive name to help identify the task later.

Source database

ParameterDescription
Instance TypeSelect User-Created Database in ECS Instance.
Instance RegionSelect the region where the ECS instance is deployed.
ECS instance IDEnter the ID of the ECS instance hosting the MongoDB database.
Database TypeSelect MongoDB.
Port NumberEnter the service port of the self-managed MongoDB database.
Database NameEnter the name of the database used for authentication.
Database AccountEnter the account used to connect to the source database.
Database PasswordEnter the account password. Click Test Connectivity to verify. If the connection succeeds, Passed appears. If it fails, click Check next to Failed to correct the settings.

Destination database

ParameterDescription
Instance TypeSelect MongoDB Instance.
Instance RegionSelect the region where the ApsaraDB for MongoDB instance resides.
MongoDB Instance IDSelect the destination ApsaraDB for MongoDB instance.
Database NameEnter the name of the database used for authentication.
Database AccountEnter the account used to connect to the destination database.
Database PasswordEnter the account password. Click Test Connectivity to verify.

Step 3: Configure the whitelist

Click Set Whitelist and Next in the lower-right corner.

DTS automatically adds its server CIDR blocks to the IP whitelist of the ApsaraDB for MongoDB instance and the security rules of the ECS instance. No manual changes are needed.

Important

If the data source or destination is a self-managed database and the public CIDR blocks of DTS servers are added to the IP whitelist of the self-managed database to allow access from DTS servers, security risks may occur. We recommend that you strengthen authentication with accounts and passwords, restrict allowed ports, or connect to the database over Express Connect, VPN Gateway, or Smart Access Gateway.

Important

After the migration is complete, remove the DTS server CIDR blocks from the whitelists. For the list of DTS server CIDR blocks, see Add the CIDR blocks of DTS servers.

Step 4: Select migration types and objects

Migration Type

Select one of the following options:

  • Full Data Migration only: Copies all existing data. Do not write to the source database during the migration to ensure data consistency.

  • Full Data Migration + Incremental Data Migration: Keeps workloads running throughout the migration. For standalone databases, enable oplog before starting (see Preparations).

Source Objects

Select objects from the Source Objects list and click the icon to add them to Selected Objects. You can select databases, collections, or functions.

Note

DTS cannot migrate the admin or local databases. To rename objects in the destination, use the object name mapping feature.

Step 5: Run the precheck

Click Precheck in the lower-right corner. The migration task starts only after the precheck passes.

If the precheck fails, click the Tip icon next to each failed item to view details. Fix the issues and run the precheck again.

Step 6: Start the migration

  1. After the precheck passes, click Next.

  2. In the Confirm Settings dialog box, select an Instance Class.

  3. Read and accept the Data Transmission Service (Pay-As-You-Go) Service Terms.

  4. Click Buy and Start.

Full data migration: Wait for the task to complete. Do not end the task manually — doing so may cause incomplete data migration.

Incremental data migration: The task does not stop automatically. End it manually when you are ready to cut over:

  1. When the task progress bar displays Incremental Data Migration and The migration task is not delayed, stop writing data to the source database for a few minutes. Wait until the progress bar displays the delay time of the incremental data migration next to Incremental Data Migration.

  2. After the status of Incremental Data Migration changes to The migration task is not delayed, manually end the migration task.

Incremental data migration without delay

Step 7: Switch your workloads

After the migration task ends, switch your applications to the destination ApsaraDB for MongoDB instance.

Related topics