This topic describes how to restore the data of an ApsaraDB for MongoDB instance to self-managed MongoDB databases by using logical backup. Data restoration uses the mongorestore command. You must have created a logical backup and downloaded the logical backup file to the server where you plan to run the mongorestore command.
- A replica set instance with three or more nodes is created.
- The ApsaraDB for MongoDB instance and the self-managed MongoDB databases run the same database version.
Full logical backup uses the mongodump command to back up a database. During the backup process, you can still perform read/write operations on the database.
- Log on to the ApsaraDB for MongoDB console.
- In the upper-left corner of the page, select the resource group and the region of the target instance.
- In the left-side navigation pane, click Replica Set Instances.
- Find the target instance and click its ID.
- In the upper-right corner of the page, click Back up Instance.
- In the Back up Instance panel, select Logical Backup for Backup Method.
- Click OK. Then, wait for the backup to complete.
- On the Backup and Recovery page, find the logical backup file and choose .
- Copy the downloaded file to the server where you plan to run the mongorestore command.
- Run the following command to import the file to self-managed MongoDB databases:
mongorestore -h <hostname> --port <server port> -u <username> -p <password> --drop --gzip --archive=<backupfile> -vvvv --stopOnError
- <hostname>: the address of the server where the self-managed MongoDB databases reside. If you also run the mongorestore command on this server, enter 127.0.0.1.
- <server port>: the port number of the self-managed MongoDB databases.
- <password>: the password of the preceding account.
- <backupfile>: the name of the logical backup file you downloaded.
mongorestore -h 127.0.0.1 --port 27017 -u root -p xxxxxxxx --drop --gzip --archive=hins1111_data_20190710.ar -vvvv --stopOnError