This topic describes how to restore the data of an ApsaraDB for MongoDB instance to user-created 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 (three- or more-node) is used.
- The ApsaraDB for MongoDB instance and the user-created 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 region where the source instance resides.
- In the left-side navigation pane, click Replica Set Instances.
- Find the source instance and click its ID.
- In the upper-right corner of the page, click Backup Instance.
- In the Backup Instance dialog box that appears, select the Logical Backup method.
- Click OK. Then, wait until the backup is complete.
- On the Backup and Recovery page, find the target logical backup file and choose in the Operation column.
- Copy the downloaded file to the server where you plan to run the mongorestore command.
- Run the following command to import the file to user-created 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 user-created 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 user-created 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