In order to backup a MongoDB database, you use the `mongodump` command-line utility. It is a part of the standard MongoDB distribution package and is located in the bin directory.
Here is a simple command to backup a MongoDB database:
```
mongodump —db
```
Replace `
This command will create a binary export of the contents of a database. If the operation is successful, `mongodump` will create a BSON file for each collection in the database, as well as an `oplog.bson` file and a `metadata.json` file for each collection.
By default, `mongodump` connects to the MongoDB instance running on the localhost with the default port of 27017. If your setup is different or requires authentication, you need to provide additional parameters.
For example, to backup a MongoDB database running on a different host or port:
```
mongodump —host mongodb.example.net —port 27017 —db
```
In order to backup a MongoDB database that requires authentication:
```
mongodump —username
```
Replace `
Keep in mind that `mongodump` and `mongorestore` are simple and efficient for backing up small MongoDB databases, but for large systems (several GBs or more) other backup methods like file system snapshots or replication to a secondary MongoDB server may be more appropriate.