This guide walks you through migrating data from a MongoDB Atlas database to an ApsaraDB for MongoDB instance using Data Transmission Service (DTS). DTS supports full data migration and incremental data migration. Selecting both types keeps your services online throughout the migration.
In this guide, you will:
-
Add DTS server IP addresses to the MongoDB Atlas allowlist
-
Configure source and destination database connections in DTS
-
Select migration types and objects
-
Run a precheck and purchase a DTS instance
-
Switch workloads to ApsaraDB for MongoDB
Prerequisites
Before you begin, make sure that you have:
-
An ApsaraDB for MongoDB instance with available storage at least 10% larger than the total data size in the source MongoDB Atlas database (recommended)
-
A MongoDB Atlas database account with the required permissions (see Permissions required)
-
An ApsaraDB for MongoDB database account with read and write permissions on the destination database
Limits
-
DTS reads from the source and writes to the destination concurrently during full data migration, increasing load on both database servers. Migrate data during off-peak hours to minimize impact.
-
DTS cannot migrate data from the
adminorlocaldatabase. Theconfigdatabase is an internal database; migrating it is not recommended. -
If the source and destination MongoDB databases use different versions or storage engines, verify that your applications can run on both. For supported versions and storage engines, see MongoDB versions and storage engines.
-
Concurrent writes to the destination database cause the destination storage size to be 5%–10% larger than the source data size.
-
The destination ApsaraDB for MongoDB instance must not contain documents with the same
_idprimary key as documents in the source. Otherwise, data may be lost. If conflicts exist, delete the matching documents from the destination before starting the migration, without affecting your business.
Billing
| Migration type | Instance configuration fee | Internet traffic fee |
|---|---|---|
| Full data migration | Free | Charged only when data is migrated from Alibaba Cloud over the Internet. For details, see Billing overview. |
| Incremental data migration | Charged. For details, see Billing overview. |
Migration types
| Migration type | Description | Supported objects |
|---|---|---|
| Full data migration | Migrates existing data from the source MongoDB database to the destination. | Databases, collections, and indexes |
| Incremental data migration | After full data migration completes, continuously replicates changes from the source to the destination. Supports create and delete operations on databases, collections, and indexes, and create, delete, and update operations on documents. | Databases, collections, indexes, and documents |
Permissions required
| Database | Full data migration | Incremental data migration |
|---|---|---|
| Source MongoDB Atlas database | Read permissions on the source database and the listDatabases permission |
Read permissions on the source, admin, and local databases, and the listDatabases permission |
| Destination ApsaraDB for MongoDB instance | Read and write permissions on the destination database | Read and write permissions on the destination database |
For information about how to create a database account and grant the required permissions on MongoDB Atlas, see db.createUser().
For the ApsaraDB for MongoDB destination instance, see Use DMS to manage database accounts.
Add DTS server IP addresses to the MongoDB Atlas allowlist
DTS requires network access to your MongoDB Atlas database. Complete this step before configuring the migration task.
-
Log on to the MongoDB Atlas console.
-
In the left-side navigation pane, click Network Access.
-
On the IP Whitelist tab, click ADD IP ADDRESS.
-
Add the DTS server IP addresses for the region where your source MongoDB Atlas database resides. For DTS IP address ranges, see Add the CIDR blocks of DTS servers. For MongoDB Atlas instructions, see Add IP Access List Entries.
Delete this security rule after the migration is complete to reduce security exposure.
Configure the migration task (new DTS console)
Step 1: Open the Data Migration page
Use one of the following methods:
DTS console
-
Log on to the DTS console.
-
In the left-side navigation pane, click Data Migration.
-
In the upper-left corner, select the region where the data migration instance resides.
DMS console
The actual navigation may vary based on the mode and layout of the DMS console. For details, see Simple mode and Customize the layout and style of the DMS console.
-
Log on to the DMS console.
-
In the top navigation bar, move the pointer over Data + AI > DTS (DTS) > Data Migration.
-
From the drop-down list to the right of Data Migration Tasks, select the region where the data migration instance resides.
Step 2: Configure source and destination databases
-
Click Create Task.
-
Read the Limits displayed at the top of the page before proceeding. Ignoring these limits may cause task failure or data inconsistency.
-
Configure the source and destination databases using the following parameters.
Source database (MongoDB Atlas)
| Parameter | Description |
|---|---|
| Task Name | A name for the DTS task. DTS generates one automatically. Specify a descriptive name for easy identification. The name does not need to be unique. |
| Select a DMS database instance | Select an existing database instance to auto-populate the parameters, or configure the connection manually. To register a new instance, click Add DMS Database Instance. For details, see Register an Alibaba Cloud database instance and Register a database hosted on a third-party cloud service or a self-managed database. |
| Database Type | Select MongoDB. |
| Access Method | Select Public IP Address. |
| Instance Region | The region where the MongoDB Atlas database resides. If the region is not listed, select the geographically closest region. |
| Architecture | Select Replica Set. |
| Domain Name or IP | The endpoint of the PRIMARY node in the MongoDB Atlas database. Obtain this endpoint from the MongoDB Atlas console. |
| Port Number | The service port of the MongoDB Atlas database. Default: 27017. |
| Authentication Database | The authentication database where the database account was created. |
| Database Account | The MongoDB Atlas account. For required permissions, see Permissions required. |
| Database Password | The password for the database account. |
| Encryption | Select Mongo Atlas SSL. |
Destination database (ApsaraDB for MongoDB)
| Parameter | Description |
|---|---|
| Select a DMS database instance | Select an existing database instance to auto-populate the parameters, or configure the connection manually. |
| Database Type | Select MongoDB. |
| Access Method | Select Alibaba Cloud Instance. |
| Instance Region | The region where the destination ApsaraDB for MongoDB instance resides. |
| Architecture | The architecture of the destination instance: Replica Set or Sharded Cluster. For details, see Replica set instances and Sharded cluster instances. |
| Instance ID | The ID of the destination ApsaraDB for MongoDB instance. |
| Authentication Database | The authentication database where the database account was created. Enter admin to use the root account. |
| Database Account | The ApsaraDB for MongoDB account. For required permissions, see Permissions required. |
| Database Password | The password for the database account. |
Step 3: Test connectivity
In the lower part of the page, click Test Connectivity and Proceed, then click Test Connectivity in the CIDR Blocks of DTS Servers dialog box.
DTS server CIDR blocks must be added to the security settings of the source and destination databases. For details, see Add the CIDR blocks of DTS servers.
Step 4: Configure migration objects
On the Configure Objects page, set the following parameters.
| Parameter | Description |
|---|---|
| Migration Types | Select Schema Migration + Full Data Migration for a one-time migration. Select Schema Migration + Full Data Migration + Incremental Data Migration to keep services online during migration. If you omit Schema Migration, create the target database and collections manually before starting. If you omit Incremental Data Migration, stop writing to the source database during migration to maintain data consistency. |
| Processing Mode of Conflicting Tables | Precheck and Report Errors: checks for collection name conflicts before migration starts. The task fails if conflicts are found. Use object name mapping to resolve conflicts. Ignore Errors and Proceed: skips the conflict check. Use this only if you accept the risk of data inconsistency — DTS skips records with conflicting primary keys and does not overwrite destination data. |
| Capitalization of Object Names in Destination Instance | Controls capitalization of database and collection names in the destination. Default: DTS default policy. For details, see Specify the capitalization of object names in the destination instance. |
| Source Objects | Select one or more databases or collections from Source Objects and click the arrow icon to move them to Selected Objects. |
| Selected Objects | To rename a single object, right-click it in Selected Objects. For details, see Map the name of a single object. To rename multiple objects at once, click Batch Edit. For details, see Map multiple object names at a time. Note that renaming an object may cause dependent objects to fail migration. |
Click Next: Advanced Settings.
Step 5: Configure advanced settings
| Parameter | Description |
|---|---|
| Retry Time for Failed Connections | How long DTS retries after a connection failure. Valid values: 10–1,440 minutes. Default: 720 minutes. Set this to at least 30 minutes. If DTS reconnects within this window, the task resumes automatically. Note that retry time is billed. |
| Retry Time for Other Issues | How long DTS retries after DDL or DML operation failures. Valid values: 1–1,440 minutes. Default: 10 minutes. Set this to greater than 10 minutes. Must be less than Retry Time for Failed Connections. |
| Enable Throttling for Full Data Migration | Limits the read and write load on the databases during full data migration. Configure Queries per second (QPS) to the source database, RPS of Full Data Migration, and Data migration speed for full migration (MB/s). Available only when Full Data Migration is selected. |
| Enable Throttling for Incremental Data Migration | Limits the load during incremental data migration. Configure RPS of Incremental Data Migration and Data migration speed for incremental migration (MB/s). Available only when Incremental Data Migration is selected. |
| Environment Tag | An optional tag to identify the DTS instance. |
| Configure ETL | Enables the extract, transform, and load (ETL) feature. Select Yes to enter data processing statements in the code editor. For details, see Configure ETL in a data migration or data synchronization task. |
| Monitoring and Alerting | Configures alerts for task failure or latency exceeding a threshold. Select Yes to set alert thresholds and notification contacts. For details, see Configure monitoring and alerting. |
Click Next Step: Data Verification to configure a data verification task. For details, see Configure a data verification task.
Step 6: Run a precheck
Click Next: Save Task Settings and Precheck.
To preview the OpenAPI parameters for this task before saving, move the pointer over Next: Save Task Settings and Precheck and click Preview OpenAPI parameters.
DTS runs a precheck before the task can start. If the precheck fails:
-
Click View Details next to a failed item to see the cause, fix the issue, and click Precheck Again.
-
If an alert item can be ignored, click Confirm Alert Details > Ignore > OK > Precheck Again. Ignoring alerts may result in data inconsistency.
Step 7: Purchase a DTS instance and start the task
-
Wait until Success Rate reaches 100%, then click Next: Purchase Instance.
-
On the Purchase Instance page, configure the following parameters.
Parameter Description Resource Group The resource group for the DTS instance. Default: default resource group. For details, see What is Resource Management? Instance Class The instance class determines migration speed. Select a class based on your data volume and time requirements. For details, see Instance classes of data migration instances. -
Read and select the checkbox to agree to Data Transmission Service (Pay-as-you-go) Service Terms.
-
Click Buy and Start, then click OK.
Track the task progress on the Data Migration page.
Configure the migration task (old DTS console)
If you are using the new DTS console, follow Configure the migration task (new DTS console) instead.
-
Purchase a data migration instance. For details, see Purchase a DTS instance.
-
Log on to the DTS console.
If you are redirected to the Data Management Service (DMS) console, click the
icon in the
to switch to the previous version of the DTS console. -
In the left-side navigation pane, click Data Migration.
-
In the upper part of the Migration Tasks page, select the region where the ApsaraDB for MongoDB instance resides.
-
Find the data migration instance and click Configure Migration Task.
-
Configure the source and destination databases.
Source database
Parameter Description Task Name The task name. DTS generates one automatically. Specify a descriptive name for easy identification. Instance Type Select User-Created Database with Public IP Address. Instance Region Not required when Instance Type is User-Created Database with Public IP Address. Database Type Select MongoDB. Hostname or IP Address The endpoint of the PRIMARY node in the MongoDB Atlas database. The following animation shows how to obtain the endpoint. 
Port Number The service port of the MongoDB Atlas database. Default: 27017. Database Name The authentication database where the database account was created. Database Account The MongoDB Atlas account. For required permissions, see Permissions required. Database Password The password for the database account. After entering the password, click Test Connectivity to verify. A Passed message confirms the connection. Encryption Select SSL-encrypted. Destination database
Parameter Description Instance Type Select MongoDB Instance. Instance Region The region where the ApsaraDB for MongoDB instance resides. MongoDB Instance ID The ID of the ApsaraDB for MongoDB instance. Database Name The authentication database where the database account was created. Enter adminto use the root account.Database Account The ApsaraDB for MongoDB account. For required permissions, see Permissions required. Database Password The password for the database account. After entering the password, click Test Connectivity to verify. 
-
Click Set Whitelist and Next. DTS automatically adds its server CIDR blocks to the IP address whitelist of Alibaba Cloud database instances. For self-managed databases hosted on Elastic Compute Service (ECS) instances, DTS adds the CIDR blocks to the ECS security group rules. For databases deployed in data centers or on third-party clouds, add the DTS CIDR blocks manually. For details, see Add the CIDR blocks of DTS servers.
WarningAdding DTS CIDR blocks to your allowlist exposes your database to network access from DTS servers. Before proceeding, review the security implications and take preventive measures: use strong credentials, restrict exposed ports, authenticate API calls, audit whitelist rules regularly, and remove unauthorized CIDR blocks promptly. For private connectivity, use Express Connect, VPN Gateway, or Smart Access Gateway.
-
Select migration types and objects.
Setting Description Migration types Select Full Data Migration for a one-time migration. Select Full Data Migration + Incremental Data Migration to keep services online during migration. If you omit Incremental Data Migration, stop writing to the source database during migration to maintain data consistency. Objects to migrate In the Available section, select databases or collections, then click the arrow icon to move them to Selected. DTS cannot migrate the admin,local, orconfigdatabases. Objects can be databases, collections, or functions. To rename objects in the destination, use the object name mapping feature. For details, see Object name mapping.Retry time for failed connections How long DTS retries after a connection failure. Default: 12 hours. If DTS reconnects within this window, the task resumes. Note that retry time is billed. -
Click Precheck.
DTS runs a precheck before the task can start. If the precheck fails, click the info icon next to a failed item to see the cause. Fix the issue and click Precheck again. You can also ignore non-critical failed items and rerun the precheck.
-
After the precheck passes, click Next.
-
In the Confirm Settings dialog box, configure the Instance Class and select the checkbox to agree to Data Transmission Service (Pay-As-You-Go) Service Terms.
-
Click Buy and Start.
Monitor and stop the migration
Full data migration
Do not manually stop a full data migration task. Wait for it to stop automatically. Stopping it early may leave the destination database incomplete.
Incremental data migration
Incremental data migration does not stop automatically. Stop it manually when ready to cut over.
To stop the incremental migration cleanly:
-
Wait until the task progress bar shows Incremental Data Migration and The data migration task is not delayed.
-
Stop writing to the source database and wait a few minutes.
-
Wait until the Incremental Data Migration status changes to The migration task is not delayed again.
-
Manually stop the migration task.

Stop the migration during off-peak hours or immediately before switching workloads to ApsaraDB for MongoDB.
What's next
After stopping the migration task, switch your workloads to the destination ApsaraDB for MongoDB instance.