Forrest logo
back to the mongodump tool

mongodump:tldr:b3a27

mongodump: Create a dump of all databases (this will place the files inside a directory called "dump").
$ mongodump
try on your machine

The mongodump command is a utility provided by MongoDB to create a binary export of the data stored in a MongoDB database. It is used to create a backup of the database, which can be later restored using the mongorestore command.

Here is a breakdown of the mongodump command:

  • mongodump is the actual command that needs to be executed.
  • By default, mongodump connects to the MongoDB server running on localhost at the default port 27017. To specify a different server or port, you can use the --host and --port options.
  • The --db option allows you to specify the name of the database that you want to backup. If you do not provide this option, mongodump will dump all databases on the server.
  • You can use the --collection option to specify a specific collection to backup within the specified database.
  • By default, mongodump creates a directory named dump in the current working directory to store the backup files. You can change the output directory using the --out option followed by the desired directory path.
  • Other options, such as --username and --password, can be used to authenticate against the server if it requires authentication.

When you execute the mongodump command with the desired options, it will generate binary BSON dump files for the specified database or collection, storing them in the designated output directory. These dump files can later be restored using the mongorestore command to recover the data.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the mongodump tool