MongoDB database Backup and Recovery

Source: Internet
Author: User
Tags mongodb server mongodump mongorestore

1. MongoDB database backup     1, Syntax:        mongodump-h dbhost-d dbname-o dbdirectory    &NB Sp   parameter Description:           -H:MONGDB server address, for example: 127.0.0.1, you can also specify the port number:127.0.0.1:27017  & nbsp        -D: Database instances that need to be backed up, such as:test           -o: Data storage location for backup, for example:/home/mongodu mp/, of course, the directory needs to be established in advance, this directory contains the database instance backup data.     2, example:        sudo rm-rf/home/momgodump/        sudo mkdir-p/home /momgodump        sudo mongodump-h 127.0.0.1:27017-d test-o/home/mongodump/      &N Bsp -3. To see if the backup was successful: The Test folder appears in the  /home/mongodump/directory, indicating a successful backup 2, MongoDB database recovery     1, Syntax:        Mongorestore-h dbhost-d dbname--dir dbdirectory         parameter or name:        &NBSP ;  -H:MONGODB server address            -D: DB instance that needs to be restored, for example: Test, of course this nameIt can also be different from the time of backup, such as test2           --dir: Where to back up your data, such as:/home/mongodump/test           --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!     2, instance:    mongorestore-h 192.168.17.129:27017-d test02--dir/home/mongodump/test/ -3 , check whether the import is successful:   Enter the database to see if the data exists

MongoDB database backup and recovery

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.