MongoDB data file backup and recovery

Source: Internet
Author: User
Tags mongodb mongodb download mongodb server port number mongodump mongorestore
MongoDB data file backup and recovery backup and recovery data are important for managing any data storage system. 1, cold backup and recovery-Create a copy of the data file (if you want to stop the MongoDB server), that is, direct copy MongoDB will store all the data in the data directory, the default is/data/db/(under Windows is C:\data\db\),  When you start MongoDB, you can also use--dbpath to specify the data store directory that we set ourselves.  Back up MongoDB data: Simply create a copy of the data store directory and copy it directly.    Recover MongoDB Data: Specify the location of the data store directory copy with--dbpath at MongoDB startup. In the case of the server running the direct copy is risky, may be copied out, the data has been destroyed, this way to create a copy of the data directory needs to close the MongoDB server, the data directory is to close that moment of data snapshot,   You can replicate the directory as a backup before the server restarts. 2, hot backup and recovery--mongodb bin directory with the Mongodump and Mongorestore tools

MongoDB also provides backup and recovery capabilities, respectively, Mongdump.exe and Mongorestore.exe files in the MongoDB download directory.

first introduce the following command syntax:

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

>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: The location of the backup data, for example: C:\data\dump\test, why do you want to add a test, instead of the backup time dump, the reader himself to check the hint.

--drop: When recovering, delete the current data and then restore the backed up data. That is, after the recovery, add the modified data after the backup will be deleted, use with caution oh.

Instance operations:

Original address: http://mib168.iteye.com/blog/1826027

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.