Using MongoDB Command-Line Tools
1. Using mongodump Utility
| Flag | Detail |
|---|---|
| --uri | Connection string |
| --archive --gzip | Compressed single-file dump |
| --oplog | Point-in-time consistency |
2. Using mongorestore Utility
| Flag | Detail |
|---|---|
| --drop | Drop before restore |
| --nsFrom / --nsTo | Rename during restore |
| --numParallelCollections | Concurrency |
3. Using mongoexport Utility
| Flag | Detail |
|---|---|
| --type | json|csv |
| --query | Filter |
| --fields | Required for CSV |
4. Using mongoimport Utility
| Flag | Detail |
|---|---|
| --mode | insert|upsert|merge|delete |
| --upsertFields | Match fields for upsert |
| --numInsertionWorkers | Parallelism |
5. Using mongostat for Real-Time Monitoring
mongostat --uri="$URI" --discover 2
6. Using mongotop for Read/Write Activity
mongotop --uri="$URI" 5
7. Using mongofiles for GridFS Operations
| Subcommand | Detail |
|---|---|
| put / get | Upload / download |
| list / search | Browse files |
| delete | Remove by filename |
8. Using bsondump for BSON Conversion
bsondump --type=json users.bson > users.json
9. Using mongoreplay for Traffic Recording
| Status | Detail |
|---|---|
| Deprecated | Removed from mainline tools |
| Use instead | Atlas Query Profiler / FTDC for capture |
10. Understanding Tool Authentication Options
| Flag | Detail |
|---|---|
| --username / --password | Basic auth |
| --authenticationDatabase | Where the user is defined |
| --authenticationMechanism | SCRAM-SHA-256, MONGODB-X509, GSSAPI, PLAIN, MONGODB-AWS |
| --tls* flags | TLS configuration |