MongoDB Finishing notes のdump & Restore

Source: Internet
Author: User
Tags mongodump

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.