https://roadmap.sh/projects/database-backup-utility
A command-line interface (CLI) utility for backing up MySQL and MongoDB databases with support for compression and local storage.
- Features
- Prerequisites
- Installation
- Configuration
- Usage
- Logging
- Error Handling
- Limitations
- Contributing
- License
✨ Key features of the Database Backup CLI:
- Support for MySQL and MongoDB databases
- Interactive configuration setup
- Full database backups with compression
- Local storage for backup files
- Detailed activity logging
- Database restore capabilities
- Cross-platform compatibility
Before installing the CLI, ensure you have:
- Node.js 16.x or higher
- npm 8.x or higher
- MySQL Binaries (if using MySQL backups)
- MongoDB Binaries (if using MongoDB backups)
Install the CLI globally via npm:
npm install -g snapbaseThis allows you to run the snapbase command directly from the terminal.
snapbase configure --out ./backup-config.jsonOr install locally in your project:
npm install snapbasenpx snapbase configure --out ./backup-config.jsonUse the interactive configuration command to set up your database connection:
snapbase configure --out ./backup-config.jsonThis will create a configuration file with the following structure:
For MySQL:
{
"type": "mysql",
"host": "localhost",
"port": "3306",
"user": "your_username",
"password": "your_password",
"databaseName": "your_database",
"backupDir": "./backup"
}For MongoDB:
{
"type": "mongodb",
"uri": "mongodb://localhost:27017",
"databaseName": "your_database",
"backupDir": "./backup"
}Set up your database connection settings:
snapbase configure [options]Options:
--out <path>: Path to save configuration file (default: ./backup-config.json)
Create a database backup:
snapbase backup [options]Options:
--config <path>: Path to configuration file (default: ./backup-config.json)
Restore a database from backup:
snapbase restore [options]Options:
--config <path>: Path to configuration file (default: ./backup-config.json)
The CLI automatically logs all backup and restore activities to backup.log in the application directory. Each log entry includes:
- Command executed
- Start time
- End time
- Status
- Time taken
- Any errors encountered
The CLI includes comprehensive error handling for:
- Database connection failures
- Invalid configuration
- Backup/restore operation failures
All errors are:
- Displayed in the console with helpful messages
- Logged to the activity log file
- Include relevant error codes and suggestions
Current limitations of the CLI:
- Supports MySQL and MongoDB databases only
- Full backups only (no incremental or differential backups)
- Local storage only (no cloud storage options)
- No notification system
- No partial backup/restore functionality
Contributions are welcome! To contribute:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
📦 NPM Package | 🐛 Report Bug | ✨ Request Feature