MongoDB Import Export Backup restore

Source: Internet
Author: User
Tags mongodump mongorestore

MongoDB database is also inseparable from the necessary maintenance, such as backup, recovery, import, export.

In fact, backup and recovery is easier than import and export, and generally does not make mistakes, so most of the time using backup and recovery operations.

1. Back Up MongoDB

Mongodump-h ruiyip-d Dataname-o/home/aa/dev/mongodb/data

Mongodump MONGO Export Database command Mongodump--HELP can see all the help under the command

-H Export Source

-d database name to export

The location to export the-o database

After the terminal rolls over n rows, the database export is completed, you can go to the/home/aa/dev/mongodb/data directory to view the exported files, Bson format (I export did not immediately see the file, waited for a while to appear, unexplained)

2. Restore using: Mongorestore command

Mongorestore-d Cmsdev/home/xx/dev/mongodb/data/cmsdev

-d database name used

Add directly to the directory you just exported, so that all tables are restored directly

If-C is the recovery of a table

3. Import

mongoimport-d my_mongodb-c User User.dat

Parameter description:

-d indicates which library to use, in this case "My_mongodb"

-C indicates the table to be exported, in this case "user"

You can see that the table structure is created implicitly when importing data

4. Export

mongoexport-d my_mongodb-c User-o User.dat

Parameter description:

-d indicates which library to use, in this case "My_mongodb"

-C indicates the table to be exported, in this case "user"

-O indicates the name of the file to be exported, in this case "User.dat"

From the above you can see how the export is using the JSON style

MongoDB Import Export Backup 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.