mongodump

A backup can be as simple as issuing the command mongodump. This command will create a binary export of either a mongod or a mongos instance. Here is the output for the MongoDB instance, which is used to demonstrate concepts in this book:

There are a number of options available with this command. You can gain quick access to help by typing mongodump --help. The complete list is far too numerous to detail here, so we are including only certain key parameters, which are summarized in the following table. The options are switches which follow the mongodump command:

-d <database>   | --db=<database> Which database to dump.
-c <collection> ...

Get MongoDB 4 Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.