Skip to content

mongodb/mongo-tools

Folders and files

NameName
Last commit message
Last commit date
Aug 6, 2024
Feb 27, 2025
Feb 28, 2025
Jan 31, 2025
Aug 2, 2024
May 30, 2024
Jun 12, 2024
Feb 27, 2025
Feb 27, 2025
Aug 6, 2024
Feb 27, 2025
Feb 28, 2025
Aug 6, 2024
Aug 6, 2024
Feb 27, 2025
Feb 24, 2025
Feb 24, 2025
Feb 27, 2025
Feb 12, 2025
Jun 13, 2024
Jun 7, 2024
Sep 19, 2014
Jun 25, 2024
Aug 2, 2024
Sep 26, 2022
Feb 3, 2025
Feb 24, 2025
Jun 7, 2024
Jun 7, 2024
Feb 5, 2025
Feb 24, 2025
Jun 7, 2024
Feb 12, 2025
Apr 30, 2024
Aug 29, 2024
Feb 24, 2025
Feb 12, 2025
Feb 12, 2025
Feb 12, 2025
Oct 20, 2020
Feb 4, 2025
Feb 4, 2025
Aug 8, 2024
Jan 15, 2025
Sep 4, 2024

Repository files navigation

MongoDB Tools

  • bsondump - display BSON files in a human-readable format
  • mongoimport - Convert data from JSON, TSV or CSV and insert them into a collection
  • mongoexport - Write an existing collection to CSV or JSON format
  • mongodump/mongorestore - Dump MongoDB backups to disk in .BSON format, or restore them to a live database
  • mongostat - Monitor live MongoDB servers, replica sets, or sharded clusters
  • mongofiles - Read, write, delete, or update files in GridFS
  • mongotop - Monitor read/write activity on a mongo server

Report any bugs, improvements, or new feature requests at https://jira.mongodb.org/browse/TOOLS

Building Tools

We currently build the tools with Go version 1.15. Other Go versions may work but they are untested.

Using go get to directly build the tools will not work. To build them, it's recommended to first clone this repository:

git clone https://github.com/mongodb/mongo-tools
cd mongo-tools

Then run ./make build to build all the tools, placing them in the bin directory inside the repository. Run ./bin/mongodump --help to verify that the built binary works.

You can also build a subset of the tools using the -pkgs option. For example, ./make build -pkgs=mongodump,mongorestore builds only mongodump and mongorestore.

To use the build/test scripts in this repository, you must set GOROOT to your Go root directory. This may depend on how you installed Go.

export GOROOT=/usr/local/go

Mac OS only:

When running the built binaries, if the process gets killed immediately and you see the following output:
zsh: killed ./bin/mongodump --help
Then you need to sign the binary in order to run it:
codesign --force --sign - bin/mongodump

You can also choose to configure the security policy of the terminal application so that signing is not required:
(in macOS Sonoma) System Settings > Privacy & Security > Developer Tools

Updating Dependencies

Starting with version 100.3.1, the tools use go mod to manage dependencies. All dependencies are listed in the go.mod file and are directly vendored in the vendor directory.

In order to make changes to dependencies, you first need to change the go.mod file. You can manually edit that file to add/update/remove entries, or you can run the following in the repository directory:

go mod edit -require=<package>@<version>  # for adding or updating a dependency
go mod edit -droprequire=<package>        # for removing a dependency

Then run go mod vendor -v to reconstruct the vendor directory to match the changed go.mod file.

Optionally, run go mod tidy -v to ensure that the go.mod file matches the mongo-tools source code.

Contributing

See our Contributor's Guide.

Documentation

See the MongoDB packages documentation.

For documentation on older versions of the MongoDB, reference that version of the MongoDB Server Manual:

Adding New Platforms Support

See our Adding New Platform Support Guide.

Vendoring the Change into Server Repo

See our Vendor the Change into Server Repo.