MongoDB Backup (Mongodump) and recovery (Mongorestore)

Source: Internet
Author: User
Tags mongodb download mongodb server mongodump mongorestore

MongoDB provides backup and restore capabilities, Mongodump.exe and Mongorestore.exe files in the MongoDB download directory, respectively.

1. Back up your data using the following command:

>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.

2. Restore the data using the following command:

>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: Where to back up your data, for example: C:\data\dump\test

3. Import data can use the command:

Mongoimport-h dbhost-d dbname-c collectionname Output
Parameter description:
-H Database Address
-d indicates which library to use
-C indicates the collection to import

4. Export data you can use the command:

Mongoexport-h dbhost-d dbname-c collectionname-o output

Parameter description:
-H Database Address
-d indicates which library to use
-C indicates the collection to be exported
-O indicates the file name to export

MongoDB Backup (Mongodump) and recovery (Mongorestore)

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.