MongoDB Database backup operation

Source: Internet
Author: User
Tags mongodump mongorestore


MongoDB Database Backup


Mongodump--host mongodb.example.net--port 27017


Backup path Selection

Mongodump--out/data/backup/


Select the databases and collections to back up

Mongodump--collection mycollection--db test


Create a non-local database backup


Mongodump--host mongodb1.example.net--port 3017--username user--password "Pass"--out/opt/backup/ Mongodump-2013-10-24


=============================================================================================================== =====================================



Database recovery


Mongorestore--port <port number> <path to the backup>



Mongorestore dump-2013-10-25/


Mongorestore--oplogreplay


Mongorestore--host mongodb1.example.net--port 3017--username user--password ' pass '/opt/backup/mongodump-2013-10-24





Cold backup


Service Mongod Stop


Specify the location of the database file

Cd/backup


Mongodump--dbpath/var/lib/mongo/


Service Mongod Start



Hot backup


# Cd/backup


# mongodump--db mongodevdb--username mongodevdb--password yoursecretpwd


# ls-l dump/

Drwxr-xr-x. 2 root root 4096 Sep 7 10:08 Mongodevdb



Backup a specific Collection


# Cd/backup


# mongodump--collection employee--db mongodevdb--username mongodevdb--password yoursecretpwd


# mongodump--collection employee--db mongodevdb--username mongodevdb--password yoursecretpwd--out/dbbackup


[local-host]# mongodump--host 192.168.1.2--port 37017--db mongodevdb--username mongodevdb--password YourSecretPwd



Service Mongod Stop


Cd/backup


Mongorestore--dbpath/var/lib/mongo Dump


Cd/backup


Mongorestore--dbpath/var/lib/mongo--db Mongodevdb dump/mongodevdb



Drop the old Database before Restoring


# Cd/backup


# mongorestore--dbpath/var/lib/mongo--db mongodevdb dump/mongodevdb


# mongorestore--dbpath/var/lib/mongo--db mongodevdb--drop dump/mongodevdb


Mongorestore--host 192.168.1.2--port 3017--db mongodevdb--username mongodevdb--password yoursecretpwd--drop/backup/ Dump


MongoDB Database backup operation

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.