BackupForge is a command-line database backup utility that provides a simple and efficient way to backup and restore databases. It supports multiple database types and storage options, with features like compression and scheduling.
This project is available on GitHub at: https://github.com/RajeshBasnet-dev/Database_Backup_Utility_CLI
- 🔥 Multiple Database Support: MySQL, PostgreSQL, MongoDB, and SQLite
- 💾 Storage Options: Local storage and AWS S3
- 🗜️ Compression: ZIP and GZIP compression for backup files
- ⏰ Scheduling: Automated backup scheduling
- 📢 Notifications: Slack webhook integration for backup notifications
- 🌐 Cross-platform: Works on Windows, Linux, and macOS
- Clone the repository:
git clone https://github.com/RajeshBasnet-dev/Database_Backup_Utility_CLI.git cd Database_Backup_Utility_CLI - Install the required dependencies:
pip install -r requirements.txt
- Make sure you have the database clients installed:
- MySQL:
mysqldumpandmysql - PostgreSQL:
pg_dumpandpg_restore - MongoDB:
mongodumpandmongorestore
- MySQL:
Backup MySQL Database:
backupforge backup --db-type mysql --host localhost --username root --password root --database testdbRestore PostgreSQL Database:
backupforge restore --db-type postgres --host localhost --username postgres --password postgres --database testdb --file backup.sql| Database | Backup | Restore | Compression | Cloud Storage | Notifications |
|---|---|---|---|---|---|
| MySQL | ✅ | ✅ | ✅ | ✅ | ✅ |
| PostgreSQL | ✅ | ✅ | ✅ | ✅ | ✅ |
| MongoDB | ✅ | ✅ | ✅ | ✅ | ✅ |
| SQLite | ✅ | ✅ | ✅ | ✅ | ✅ |
graph LR
A[CLI Interface] --> B[Command Parser]
B --> C{Database Type}
C --> D[MySQL Connector]
C --> E[PostgreSQL Connector]
C --> F[MongoDB Connector]
C --> G[SQLite Connector]
D --> H[Backup/Restore Logic]
E --> H
F --> H
G --> H
H --> I{Storage Type}
I --> J[Local Storage]
I --> K[Cloud Storage]
H --> L[Compression]
H --> M[Logging]
H --> N[Notifications]
- Clone the repository:
git clone https://github.com/RajeshBasnet-dev/Database_Backup_Utility_CLI.git cd Database_Backup_Utility_CLI - Install the required dependencies:
pip install -r requirements.txt
- Make sure you have the database clients installed:
- MySQL:
mysqldumpandmysql - PostgreSQL:
pg_dumpandpg_restore - MongoDB:
mongodumpandmongorestore
- MySQL:
Create a backup of your database:
backupforge backup --db-type mysql --host localhost --port 3306 --username user --password pass --database mydbWith compression and S3 storage:
backupforge backup --db-type postgres --host localhost --username user --password pass --database mydb --compress zip --storage s3 --bucket my-backup-bucket --region us-east-1 --access-key YOUR_ACCESS_KEY --secret-key YOUR_SECRET_KEYRestore a database from a backup:
backupforge restore --db-type mysql --host localhost --port 3306 --username user --password pass --database mydb --file backup.sqlTest database connection parameters:
backupforge test-connection --db-type mongodb --host localhost --port 27017 --username user --password pass --database mydbSchedule automated backups:
backupforge schedule --db-type sqlite --database /path/to/database.db --interval 60List existing backups:
backupforge list --storage local --path /backupsOr from S3:
backupforge list --storage s3 --bucket my-backup-bucket --region us-east-1 --access-key YOUR_ACCESS_KEY --secret-key YOUR_SECRET_KEYFor Slack notifications, set the SLACK_WEBHOOK_URL environment variable:
export SLACK_WEBHOOK_URL="https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK"For S3 storage, you can provide credentials via:
- Command line arguments (
--access-key,--secret-key) - Environment variables (
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY) - AWS credentials file
# Simple backup
backupforge backup --db-type mysql --host localhost --username root --password root --database testdb
# Backup with compression to S3
backupforge backup --db-type mysql --host localhost --username root --password root --database testdb --compress gzip --storage s3 --bucket my-backups --region us-west-2 --access-key AKIA... --secret-key ...
# Backup to specific local path
backupforge backup --db-type mysql --host localhost --username root --password root --database testdb --path /my/backups# Simple backup
backupforge backup --db-type postgres --host localhost --username postgres --password postgres --database testdb
# Restore from backup
backupforge restore --db-type postgres --host localhost --username postgres --password postgres --database testdb --file backup.sql# Backup MongoDB
backupforge backup --db-type mongodb --host localhost --port 27017 --username admin --password admin --database testdb
# Backup with compression
backupforge backup --db-type mongodb --host localhost --username admin --password admin --database testdb --compress zip# Backup SQLite database
backupforge backup --db-type sqlite --database /path/to/mydb.sqlite
# Restore SQLite database
backupforge restore --db-type sqlite --database /path/to/mydb.sqlite --file backup.dbThe schedule command runs indefinitely, performing backups at the specified interval (in minutes):
# Schedule backups every 30 minutes
backupforge schedule --db-type mysql --host localhost --username user --password pass --database mydb --interval 30
# Schedule with compression and S3 storage
backupforge schedule --db-type postgres --host localhost --username user --password pass --database mydb --interval 120 --compress zip --storage s3 --bucket my-backups --region us-east-1 --access-key ... --secret-key ...Press Ctrl+C to stop the scheduler.
- Specify with
--storage local - Use
--pathto define the backup directory (defaults to./backups)
- Specify with
--storage s3 - Required parameters:
--bucket,--region,--access-key,--secret-key
--compress zip: Compress using ZIP format--compress gzip: Compress using GZIP format
BackupForge supports a shorter alias for easier usage:
Full command:
backupforge backup --db-type mysql --host localhost --username user --password pass --database mydbShorter alias:
bforge backup --db-type mysql --host localhost --username user --password pass --database mydb--host: Database host (default: localhost)--port: Database port (default: 3306 for MySQL, 5432 for PostgreSQL)--username: Database username--password: Database password--database: Database name
--host: Database host (default: localhost)--port: Database port (default: 27017)--username: Database username--password: Database password--database: Database name
--database: Path to SQLite database file
BackupForge includes comprehensive error handling:
- Connection testing before operations
- Proper cleanup of partial backups on failure
- Detailed error messages
- Logging to backupforge.log
All operations are logged to logs/backupforge.log in the current directory.
We welcome contributions from the community! Here's how you can help improve BackupForge:
- 🐛 Bug Reports: Submit detailed bug reports with reproduction steps
- ✨ Feature Requests: Suggest new features or improvements
- 🧪 Testing: Test new releases and report issues
- 📝 Documentation: Improve documentation and examples
- 🐍 Code: Fix bugs, add features, or improve code quality
- Fork the repository at https://github.com/RajeshBasnet-dev/Database_Backup_Utility_CLI
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests if applicable
- Ensure all tests pass
- Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
git clone https://github.com/RajeshBasnet-dev/Database_Backup_Utility_CLI.git
cd Database_Backup_Utility_CLI
pip install -r requirements.txt- Follow PEP 8 style guidelines
- Write clear, descriptive commit messages
- Add docstrings to all functions and classes
- Include tests for new functionality
If you have questions, feel free to open an issue or contact the maintainers.
This project is licensed under the MIT License.