No matter how much you think about it, backup of the data is always necessary, especially important data.
MongoDB also provides backup and recovery capabilities, respectively, Mongdump.exe and Mongorestore.exe files in the MongoDB download directory.
first introduce the following command syntax:
> Mongodump - H Dbhost - D dbname - o dbdirectory
-H:MONGDB the server address, for example: 127.0.0.1, you can also specify the port number: 127.0.0.1:27017
-D: The database instance that needs to be backed up, for example: test
-O: The data storage location of the backup, for example: C:\data\dump, of course, the directory needs to be established in advance, after the backup is completed, the system automatically establishes a test directory under the Dump directory, which holds the backup data of the database instance.
> Mongorestore - H Dbhost - D dbname --directoryperdb dbdirectory
-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: C:\data\dump\test, why do you want to add a test, instead of the backup time dump, 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!
Instance operations:
MongoDB Backup (mongodump) and Recovery (Mongorestore)