MongoDB Backup Recovery

Source: Internet
Author: User
Tags mongodump mongorestore

Back up the specified library mongodump-h ip-d dbname-o dir//-h back with server ip-d followed by database name No then backup all libraries-o after specifying where to back up it is a directory

Back up all libraries mongodump-h Ip-o dir

Back up the specified collection mongodump-d mydb-c testc-o/TMP/TESTC//-c Specify the collection name

Export collection to JSON file mongoexport-d mydb-c testc-o/tmp/testc.json//-O followed by a file name

Recover all Libraries Mongorestore--drop dir///Where dir is the directory name for backing up all libraries--drop optional means to delete the previous data before recovering it is not recommended

Restores the specified library mongorestore-d mydb dir///-d The name of the library to be restored dir is the directory where the library was backed up

Restore collection mongorestore-d mydb-c TESTC Dir/mydb/testc.bson//-C followed by the collection to be restored the name dir is the path to the file where the makefile was generated when you backed up the MyDB library here is the path to the Bson file

Import Collection mongoimport-d mydb-c TESTC--file/tmp/testc.json


This article from "愺 Burgundy pounding his 豩" blog, declined reprint!

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