First introduce the following command syntax:
./mongodump-h 127.0.0.1:10001-d Lietou-o/usr/local/data
-H:MONGDB the server address, for example: 127.0.0.1, you can also specify the port number: 127.0.0.1:10001
-D: The database instance that needs to be backed up, for example: Lietou
-O: The data storage location of the backup, for example:/usr/local/data, after the backup is completed, the system automatically establishes a Lietou directory in the Dump directory, which contains the backup data of the database instance.
Database restore
./mongorestore-h 127.0.0.1:10001-d Test--directoryperdb/usr/local/data/lietou/
H:mongodb server Address
-D: The database instance that needs to be restored, for example: test, and of course the name can be different from the backup time, such as Test2
--directoryperdb: The location of the backup data, for example:/usr/local/data/lietou/, why do you want to add a lietou here, rather than the dump when the backup time, the reader to check their own tips!
--drop: When recovering, delete the current data and then restore the backed up data. That is, after the recovery, add the modified data after the backup will be deleted, use with caution Oh!
Backup and recovery of MongoDB database