Replica set and sharded cluster instances support logical backup. You can start a full logical backup to back up instance data and download the logical backup file. Then, you can run a mongorestore command to recover the downloaded backup data in a user-created MongoDB instance.
Standalone instances do not support this feature. You can create an instance from a specified backup to recover data. For more information, see Create an instance based on a backup.
To guarantee compatibility, we recommend that the database version of the user-created MongoDB instance be the same as that of the ApsaraDB for MongoDB instance.
You can run a mongodump command to start a full logical backup to back up ApsaraDB for MongoDB data. During the backup, you can still read data from and write data into the ApsaraDB for MongoDB instance.
- Log on to the ApsaraDB for MongoDB console.
- In the upper-left corner of the home page, select the region where the target instance is located.
- In the left-side navigation pane, click Replica Set Instances or Sharding Instances based on the architecture of the target instance.
- Locate the target instance and click its instance ID.
- In the left-side navigation pane, click Backup and Recovery.
- In the upper-right corner of the Backup and Recovery page that appears, click Backup Instance.
- In the Backup Instance dialog box that appears, select Logical Backup as the backup method.
- Click OK and wait until the instance data is successfully backed up.
- On the Backup and Recovery page, locate the completed logical backup and choose in the Operation column.
- After downloading the backup file, run the following command to import the backup
data into the user-created MongoDB instance:
mongorestore -h <hostname> --port <server port> -u <username> -p <password> --drop --gzip --archive=<backupfile> -vvvv --stopOnError
- <hostname>: The server address of the user-created MongoDB instance. Set this parameter to 127.0.0.1 if the user-created MongoDB instance is deployed on the current server.
- <server port>: The port used by the user-created MongoDB instance.
- <username>: The database username used to log on to the user-created MongoDB instance.
- <password>: The database password used to log on to the user-created MongoDB instance.
- <backupfile>: The name of the downloaded logical backup file.
mongorestore -h 127.0.0.1 --port 27017 -u root -p xxxxxxxx --drop --gzip --archive=hins1111_data_20190710.ar -vvvv --stopOnError