mongodump exports the data in the specified instance or library table to BSON format, as well as exporting indexes and oplog, and supports specifying --gzip for data compression.
Use mongodump to export data from a single table:
mongodump --host=<ip> --port=<port> --username=<user> --password=<password> --authenticationDatabase=admin --db=<database> --collection=<collection> --out=<dir>
After the export is complete, you will see the corresponding library table directory and files in the specified directory.
If you do not specify a table name, all table data under the specified database is exported:
mongodump --host=<ip> --port=<port> --username=<user> --password=<password> --authenticationDatabase=admin --db=<database> --out=<dir>
If you do not specify the database name and table name, all database and table data of the entire instance is exported, including the admin database that comes with the system:
mongodump --host=<ip> --port=<port> --username=<user> --password=<password> --authenticationDatabase=admin --out=<dir>
The mongorestore tool can restore the data exported by mongodump to the document database service instance.
For example, restore the data backed up by mongodump to the specified instance:
mongorestore --host=<ip> --port=<port> --username=<user> --password=<password> --authenticationDatabase=admin <dir>