MongoDB non-stop machine backup

Source: Internet
Author: User

First, backup

1. Lock the database:
Use admin
Db.runcommand ({fsync:1,lock:1})
{
"Info": "Now locked against writes, use Db.fsyncunlock () to unlock",
" seealso": "Http://www.mongodb.org/display/DOCS/fsync+Command",
"OK": 1
}
Fsync: Forcing all buffers to be written to disk
Lock: Locked, unable to write (all write operations will block)
2. Start Backup ...

mongodump-d mailaccess-c mail-q ' {User: "[email protected]"} '-o/data/dump
back up mailaccess database's mail collection to/data/dump directory
- D: Which database to back up
- C: Backup which collection (optional, does not pass the default is the entire database)
- Q: Specifies the condition of the backup collection (used with the-c parameter)


3. Unlock after Backup:
Use admin
Db. $cmd. Sys.unlock.findOne ()
{"OK": 1, "info": "Unlock Completed"}


second, restore:
mongorestore-d ma–drop/data/dump/mailaccess
Restore the Mailaccess database in the/data/dump directory to the MA databases
- D: Which database to restore to
–drop means to delete the original collection (if one exists) before recovery


MongoDB non-stop machine backup

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.