Home » How to Back Up and Restore MongoDB

How to Back Up and Restore MongoDB

by Salman Chawhan
0 comment

How to Back Up and Restore MongoDB

Simple 2 command MongoDB

mongodump     –> For dump all mongodb
mongorestore  –> For restore all mongodb

You can also specify the –host and –port of the MongoDB instance that the mongodump should connect to.

For example:

mongodump –host=mongodb.example.net –port=27017

To specify a different output directory, you can use the –out or -o option:

mongodump –out=/data/backup/

To limit the amount of data included in the database dump, you can specify –db and –collection as options to mongodump. For example:

mongodump –collection=myCollection –db=test

Create Backups from Non-Local mongod Instances

The –host and –port options for mongodump allow you to connect to and backup from a remote host. Consider the following example:

mongodump –host=mongodb1.test.com –port=3017 –username=user –password=”pass” –out=/opt/backup/mongodump

Basic mongorestore Operations

The mongorestore utility restores a binary backup created by mongodump. By default, mongorestore looks for a database backup in the dump/ directory.

The mongorestore utility restores data by connecting to a running mongod directly.

mongorestore can restore either an entire database backup or a subset of the backup.

You may also like

Leave a Comment

three − 1 =

Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?
-
00:00
00:00
Update Required Flash plugin
-
00:00
00:00