
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
mongodb_backup_tool
Advanced tools
Backup all collections from any MongoDB database to JSON or CSV — with a single command.
A lightweight, zero-config CLI tool to export all collections from a MongoDB database into JSON or CSV files, organized in timestamped folders.
Perfect for:
| Feature | Supported |
|---|---|
| Export to JSON or CSV | ✅ Yes |
| Backup all collections | ✅ Yes |
| Skips system databases | ✅ Yes (admin, config, local) |
| Timestamped backup folders | ✅ Yes |
| Works with MongoDB Atlas | ✅ Yes |
Global CLI (mongo-backup) | ✅ Yes |
| No config files needed | ✅ Yes |
npm install -g mongodb-backup-tool
Requirements
mongo-backup --uri <mongodb-uri> [options]
| Flag | Alias | Description | Default |
|---|---|---|---|
--uri | -u | Required. MongoDB connection string | — |
--format | -f | Output format: json or csv | json |
--output | -o | Output directory for backups | ./backups |
mongo-backup -u "mongodb://localhost:27017/mydb" -f json
mongo-backup -u "mongodb://user:pass@host:27017/mydb" -f csv -o ./my-backups
mongo-backup \
-u "mongodb+srv://user:pass@cluster0.mongodb.net/myDatabase" \
-f json \
-o ./atlas-backup
mongo-backup -u mongodb://localhost:27017 -f csv
backups/
└── backup-2025-10-28T14-30-22-123Z/
├── mydb/
│ ├── users.json
│ ├── products.csv
│ └── orders.json
└── analytics/
└── events.csv
collection.json or collection.csv)You can also use it inside your Node.js apps:
const { backupDatabase } = require('mongodb-backup-tool');
backupDatabase(
'mongodb://localhost:27017/mydb',
'./custom-backup',
'csv'
)
.then(() => console.log('Backup done!'))
.catch(err => console.error('Failed:', err));
Never commit your MongoDB URI to Git.
Use environment variables instead:
export MONGODB_URI="mongodb+srv://user:pass@cluster0.mongodb.net/mydb"
mongo-backup -u $MONGODB_URI -f json
| Issue | Solution |
|---|---|
command not found: mongo-backup | Run npm install -g mongodb-backup-tool again |
Authentication failed | Double-check username/password in URI |
| Empty CSV files | Collection may be empty — normal behavior |
Permission denied | Run terminal as admin or use a different output folder |
Want to improve this tool?
git clone https://github.com/yourname/mongodb-backup-tool.git
cd mongodb-backup-tool
npm install
npm link # test CLI locally
"scripts": {
"test": "node test.js"
}
.zip compressionMIT © 2025 Your Name
Pratham – Feel free to reach out!
⭐ Star this repo if you found it useful!
FAQs
Backup MongoDB database collections to JSON or CSV
The npm package mongodb_backup_tool receives a total of 3 weekly downloads. As such, mongodb_backup_tool popularity was classified as not popular.
We found that mongodb_backup_tool demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.