1. MongoDB database backup 1, Syntax: mongodump-h dbhost-d dbname-o dbdirectory &NB Sp parameter Description: -H:MONGDB server address, for example: 127.0.0.1, you can also specify the port number:127.0.0.1:27017 & nbsp -D: Database instances that need to be backed up, such as:test -o: Data storage location for backup, for example:/home/mongodu mp/, of course, the directory needs to be established in advance, this directory contains the database instance backup data. 2, example: sudo rm-rf/home/momgodump/ sudo mkdir-p/home /momgodump sudo mongodump-h 127.0.0.1:27017-d test-o/home/mongodump/ &N Bsp -3. To see if the backup was successful: The Test folder appears in the /home/mongodump/directory, indicating a successful backup 2, MongoDB database recovery 1, Syntax: Mongorestore-h dbhost-d dbname--dir dbdirectory parameter or name: &NBSP ; -H:MONGODB server address -D: DB instance that needs to be restored, for example: Test, of course this nameIt can also be different from the time of backup, such as test2 --dir: Where to back up your data, such as:/home/mongodump/test --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! 2, instance: mongorestore-h 192.168.17.129:27017-d test02--dir/home/mongodump/test/ -3 , check whether the import is successful: Enter the database to see if the data exists
MongoDB database backup and recovery