Forrest logo
tool overview
On this page you find all important commands for the CLI tool mongodump. If the command you are looking for is missing please ask our AI.

mongodump

Mongodump is a command line tool provided by MongoDB for creating backups of MongoDB databases. It is used to export data from a MongoDB instance to a binary dump file format.

Using mongodump, you can take a snapshot of an entire MongoDB database or specific collections within it. It allows for flexible exporting options, providing various parameters to customize the backup process.

Mongodump captures the data and schema for the selected databases or collections, creating BSON files that contain the exported data. The tool also preserves document and index structures, allowing for seamless restoration of backups.

Mongodump can be run on any machine that has access to the MongoDB instance, and it supports both standalone MongoDB instances and replica sets. It is a platform-independent tool and works on Windows, Linux, and macOS.

The tool uses the MongoDB connection string to connect to the database, enabling you to select the MongoDB instance to back up. Additionally, mongodump supports authentication and allows for TLS/SSL encryption during the backup process.

Mongodump provides features like compression to reduce the size of backup files and the ability to dump large databases in parallel for faster exports. It also supports various output formats, including JSON and CSV, making it convenient for further data analysis or migration processes.

Restoring a backup created with mongodump is done using another command-line tool called mongorestore. This tool allows you to import the BSON files generated by mongodump back into a MongoDB instance.

In summary, mongodump is a versatile, reliable, and efficient command-line tool for creating backups of MongoDB databases, offering flexibility, data integrity, and security during the backup and restoration processes.

List of commands for mongodump:

  • mongodump:tldr:1e312 mongodump: Create a dump of a given collection within a given database.
    $ mongodump --collection ${collection_name} --db ${database_name}
    try on your machine
    explain this command
  • mongodump:tldr:66fc2 mongodump: Create a dump from a specific instance; host, user, password and database will be defined in the connection string.
    $ mongodump --uri ${connection_string}
    try on your machine
    explain this command
  • mongodump:tldr:81b65 mongodump: Create a dump of a given database.
    $ mongodump --db ${database_name}
    try on your machine
    explain this command
  • mongodump:tldr:a70a5 mongodump: Create a dump of a given database with a given username; user will be prompted for password.
    $ mongodump --username ${username} ${database} --password
    try on your machine
    explain this command
  • 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
    explain this command
  • mongodump:tldr:e58f9 mongodump: Specify an output location for the dump.
    $ mongodump --out ${path-to-directory}
    try on your machine
    explain this command
  • mongodump:tldr:fd5ea mongodump: Connect to a given host running on a given port, and create a dump.
    $ mongodump --host ${host} --port ${port}
    try on your machine
    explain this command
tool overview