mongodump Command Reference: Flags, Usage & CI Examples
mongodump writes a binary BSON backup of MongoDB data.
mongodump connects to a MongoDB server and writes BSON files (plus metadata) for a database or collection into a directory or a single --archive file. It is the standard logical backup tool.
Common flags and usage
- --uri="...": connection string
- --db / --collection: limit to one database or collection
- --out <dir>: write BSON files into a directory
- --archive[=file]: write a single archive (file or stdout)
- --gzip: compress the output
- --query '{...}': dump only matching documents
Example
shell
mongodump --uri="${MONGODB_URI}" --gzip --archive=app.archiveIn CI
A single --archive file must be read back with mongorestore --archive, while a directory dump restores from the directory. Admin-authenticated users need ?authSource=admin in the URI, the same as mongosh.
Key takeaways
- mongodump produces a BSON backup as a directory or an --archive.
- Match --archive/--gzip on dump and restore.
- authSource=admin applies to mongodump URIs too.
Related guides
mongosh Command Reference: Flags, Usage & CI ExamplesReference for mongosh: the connection string, --eval, --quiet, authSource, and a CI example that pings a Mong…
sqlite3 Command Reference: Flags, Dot-Commands & CI ExamplesReference for the sqlite3 CLI: running SQL inline, .dump, .read, .mode, -csv, and a CI example that builds an…
pg_dump Command Reference: Flags, Usage & CI ExamplesReference for pg_dump: format flags (-F c/d/t/p), -f, -t, -n, --no-owner, and a CI example that exports a Pos…