Import data

Last Updated: Jul 25, 2017

Currently, ApsaraDB for MongoDB supports two migration solutions. Incremental data synchronization is supported during MongoDB migration; that is, MongoDB can be migrated without halting the local application server.

Use Data Transmission Service (DTS) for migration

  1. Log on to MongoDB Console, click the instance ID or Manage to go to the Basic Information page, and select Import Self-Built MongoDB Data to go to the Create Migration Task page.

  2. Select MongoDB as the database type and enter the source database connection information.

    DTS Migration

  3. Use the DTS Migration Wizard to perform the migration operation.

    For detailed instructions, refer to the DTS manual.

Use the built-in command line tool for migration

MongoDB has built-in mongodump and mongorestore command lines that can import and export data.

Note: Use the mongodump and mongorestore tools of MongoDB 3.0 or later versions.

  1. Back up user-created database data.

    First, you need to connect to the self-built database and select an account with the relevant permissions. Then, execute mongodump to export the content of the self-built database. For example, execute the following statement to export all databases and create a backup file named dump.

    1. mongodump --host xxx:27017 --authenticationDatabase admin -u xxx -p xxx

    For details, refer to mongodump command official documentation.

  2. Import the backup file into ApsaraDB for MongoDB.

    Execute the mongostore command based on the backup file created in the previous step to import all data into ApsaraDB for MongoDB. For example, execute the following statement to import the entire database.

    1. mongorestore --host dds-xxx:3717 --authenticationDatabase admin -u root -p xxx dump
Thank you! We've received your feedback.