Data backup and Recovery for MongoDB

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

  First, data backup operations

In real-world scenarios, it is often necessary to back up business data for disaster preparedness, and MongoDB provides backup and recovery capabilities, namely the Mongodump.exe and Mongorestore.exe files in the MongoDB download directory, in the form of backup commands such as the following:

>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: Kaiye
-O: The backup data storage location, for example: C:\mongodump, of course, the directory needs to be established in advance, after the backup is completed, the system automatically in the dump directory to establish a backup of the DB name of the directory, this directory contains the database instance backup data.

Example: Mongodump-h localhost:27017-d kaiye-o c://mongodump

  Second, data recovery operations

    When the actual application, due to machine failure or manual shaking mistakenly deleted the database, this time you need to restore the backup data, the command format to restore the data is as follows:

>mongorestore-h dbhost-d Dbname-directoryperdb dbdirectory
-h:mongodb server Address
-D: A database instance that needs to be restored, for example: Kaiye, which can also be different from the time of backup, such as Kaiye
-directoryperdb: The location of the backup data, for example: C:\mongodump\kaiye, remember to back up the directory when the directory you are backing up ("\" + the database name that needs to be restored)

    

Data backup and Recovery for MongoDB

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.