All about Mongo Backups & Restore

Data is the center of an enterprise and application runs top of this data. It’s crucial being DBA that you protect it and make it available in case of disaster. The basic and finest way to protect your organization’s data, implementing database backup and restore plan.

Backing up databases, (either in SQL or mongo world) can protect against not only accidental loss application data, corruption, hardware failures but also basic element of having disaster recovery site in case of natural disasters. It is DBA’s job as an administrator to make sure that backups are performed and that backup tapes/drives are shipped/stored in a secure location.

Mongodump is a utility for creating a binary export of the contents of a database. It can use on database or collection level. Mongodump can work either Mongod or mongos instances.

**mongodump and mongorestore are command line utilities.**

Mongodb has released a newer version of mongo backup and restore utilities, It would be helpful to know the version first, not all options works with all versions of these utilities.

>mongorestore /version

mongorestore version: r3.4.6

git version: c55eb86ef46ee7aede3b1e2a5d184a7df4bfb5b5 –if it appears blank most probably you are running a community edition.

Go version: go1.7

os: windows

arch: amd64

compiler: gc

OpenSSL version: OpenSSL 1.0.1u 22 Sep 2016

>mongodump /version

mongodump version: r3.4.6

git version: c55eb86ef46ee7aede3b1e2a5d184a7df4bfb5b5 –-if it appears blank you are running a community edition.

Where hostname is the name of the Mongod instance, which has the database you want to backup. In case of replica, –host is prefixed by the replica set name, mongodump reads from the primary replica set member by default.

/port use this if you have mongo deployment other than default port 27017.