Backup
[Email protected] bin]#/mongodump-127.0.0.1 database:my_mongodb to dump/My_ MongoDB my_mongodb.system.indexes to dump/my_mongodb/system.indexes.bson 1 objects my_mongodb.user to dump/my_mongodb/user.bson 267648 -rwxr-xr-x 1 root Root 7508756 2011-04-06 bsondump drwxr-xr-x 3 root root 4096 04-10 23:54
View Code
At this point, a dump directory is created in the current directory to hold the backed up files and, of course, to specify the directory where the backup resides.
[Email protected] bin]#/mongodump-d my_mongodb-127.0.0.1 database:my_mongodb to my_ Mongodb_dump/my_mongodb my_mongodb.system.indexes to my_mongodb_dump/my_mongodb/ System.indexes.bson 1 objects my_mongodb.user to My_mongodb_dump/my_mongodb/ User.bson 2
View Code
In this example, the backup file exists in the My_mongodb_dump directory under the current directory
Recovery
Since the backup has just been done, let's first talk about the library My_mongodb deleted
> Use my_mongodb >"Dropped": "My_mongodb", "OK": 1> Show dbs admin (empty) Local (empty) test >
View Code
Next, we perform data recovery
[Email protected] bin]#/mongorestore-d my_mongodb my_mongodb_dump/ 127.0.0.1 one 00:03:03 my_ mongodb_dump/my_mongodb/00:03:03 00:03:03 2 objects found11 00:03:03 my_mongodb_dump/my_mongodb/00:03:03 00:03:03 {name: "_id_", ns: "My_mongodb.user", key : {_id:1}, v:000:03:03 1 objects found [[email protected] bin]#
View Code
After the validation of the database back, in fact, to restore the database, it is not necessary to delete the My_mongodb library, as long as the description of the-drop parameter, you can restore the table and then insert data into the table.
MongoDB Finishing notes のdump & Restore