{"id":37211329,"url":"https://github.com/zfhassaan/dbx","last_synced_at":"2026-01-15T00:03:53.850Z","repository":{"id":327618565,"uuid":"1109932856","full_name":"zfhassaan/dbx","owner":"zfhassaan","description":"DBX is a cross-platform database backup \u0026 restore CLI for MySQL, PostgreSQL, MongoDB, and SQLite - with scheduling, compression, cloud uploads (S3/GCS/Azure), and automated logging.","archived":false,"fork":false,"pushed_at":"2025-12-04T18:02:13.000Z","size":20775,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-08T01:33:12.654Z","etag":null,"topics":["backup-cli","backup-tool","backup-utility","cross-platform-tools","database-backup","db-backup","go-cli","golang-tools","restore-tool","restore-utility"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zfhassaan.png","metadata":{"files":{"readme":"Readme.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-04T13:38:50.000Z","updated_at":"2025-12-04T18:02:17.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/zfhassaan/dbx","commit_stats":null,"previous_names":["zfhassaan/dbx"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/zfhassaan/dbx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfhassaan%2Fdbx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfhassaan%2Fdbx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfhassaan%2Fdbx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfhassaan%2Fdbx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zfhassaan","download_url":"https://codeload.github.com/zfhassaan/dbx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfhassaan%2Fdbx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28439609,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T22:37:52.437Z","status":"ssl_error","status_checked_at":"2026-01-14T22:37:31.496Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backup-cli","backup-tool","backup-utility","cross-platform-tools","database-backup","db-backup","go-cli","golang-tools","restore-tool","restore-utility"],"created_at":"2026-01-15T00:03:53.099Z","updated_at":"2026-01-15T00:03:53.819Z","avatar_url":"https://github.com/zfhassaan.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DBX - Database Backup Utility\n\nA cross-platform CLI tool to backup and restore multiple database systems (MySQL, PostgreSQL, MongoDB, SQLite). Supports automatic scheduling, compression, cloud storage uploads (AWS S3, GCS, Azure Blob Storage), and detailed logging.\n\n[![Version](https://img.shields.io/badge/version-0.2.0-blue.svg)](https://github.com/zfhassaan/dbx/releases/tag/v0.2.0)\n[![Go Version](https://img.shields.io/badge/go-1.24+-00ADD8.svg)](https://golang.org)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)\n\n---\n\n## Features\n\n### Database Support\n- **MySQL** - Full, incremental, and differential backups\n- **PostgreSQL** - Full, incremental, and differential backups  \n- **MongoDB** - Full database backups with compression\n- **SQLite** - File-based backups with compression\n\n### Backup \u0026 Restore\n- **Multiple Backup Types**: Full, incremental, and differential backups\n- **Selective Restore**: Restore specific tables (MySQL/PostgreSQL) or collections (MongoDB)\n- **Compression**: Automatic compression using gzip/zip\n- **Connection Testing**: Verify database connectivity before operations\n\n### Cloud Storage\n- **AWS S3** - Upload backups to Amazon S3\n- **Google Cloud Storage** - Upload to GCS buckets\n- **Azure Blob Storage** - Upload to Azure containers\n\n### Automation \u0026 Monitoring\n- **Scheduling**: Automated backups using cron syntax\n- **Logging**: Comprehensive logging system with configurable log directory\n- **Notifications**: Slack webhook integration for backup status\n- **Interactive Menu**: User-friendly menu-based interface\n- **CLI Commands**: Full command-line interface using Cobra\n\n### Developer Experience\n- **Cross-Platform**: Windows, Linux, macOS support\n- **Test Suite**: 110+ comprehensive tests with coverage reporting\n- **Zero Dependencies**: No external dependencies when built\n- **Password Security**: Hidden password input for secure credential entry\n\n---\n\n## Project Structure\n\n```\ndbx/\n├── cmd/                          # CLI commands (Cobra framework)\n│   ├── root.go                   # Root command and banner\n│   ├── backup.go                 # Backup command parent\n│   ├── mysql.go                  # MySQL backup subcommand\n│   ├── postgres.go               # PostgreSQL backup subcommand\n│   ├── mongodb.go                # MongoDB backup subcommand\n│   ├── sqlite.go                 # SQLite backup subcommand\n│   ├── restore.go                # Restore command with subcommands\n│   └── schedule.go               # Schedule command (add/list)\n├── internal/\n│   ├── db/                       # Database operations\n│   │   ├── mysql.go              # MySQL backup implementation\n│   │   ├── mysql_restore.go     # MySQL restore implementation\n│   │   ├── postgres.go           # PostgreSQL backup implementation\n│   │   ├── postgres_restore.go  # PostgreSQL restore implementation\n│   │   ├── mongodb.go            # MongoDB backup implementation\n│   │   ├── mongodb_restore.go   # MongoDB restore implementation\n│   │   ├── sqlite.go             # SQLite backup implementation\n│   │   ├── sqlite_restore.go    # SQLite restore implementation\n│   │   ├── connection.go         # Database connection testing\n│   │   └── backup_types.go      # Backup type definitions\n│   ├── cloud/                    # Cloud storage handlers\n│   │   ├── storage.go            # AWS S3 upload\n│   │   ├── gcs.go                # Google Cloud Storage upload\n│   │   └── azure.go              # Azure Blob Storage upload\n│   ├── scheduler/                # Backup scheduling\n│   │   └── scheduler.go          # Cron-based scheduler\n│   ├── logs/                     # Logging utility\n│   │   └── logger.go             # Custom logger\n│   ├── notify/                   # Notifications\n│   │   └── slack.go              # Slack webhook integration\n│   └── utils/                    # Utilities\n│       └── compress.go           # Compression utilities\n├── tests/                        # Test suite\n│   ├── internal/                 # Tests mirroring internal structure\n│   │   ├── cloud/                # Cloud storage tests\n│   │   ├── db/                   # Database operation tests\n│   │   ├── logs/                 # Logger tests\n│   │   ├── notify/               # Notification tests\n│   │   ├── scheduler/            # Scheduler tests\n│   │   └── utils/                # Utility tests\n│   └── test_helpers.go           # Common test utilities\n├── scripts/                      # Build and test scripts\n│   ├── runtests/                 # Test runner\n│   │   └── main.go\n│   └── coverage/                 # Coverage analysis\n│       └── main.go\n├── config/                       # Configuration files\n│   └── schedules.json            # Scheduled backup jobs\n├── main.go                       # Interactive menu entrypoint\n├── Makefile                      # Build automation\n├── build.sh                      # Cross-compilation script (Linux/Mac)\n├── build.bat                     # Cross-compilation script (Windows)\n├── CHANGELOG.md                  # Version history\n└── README.md                     # This file\n```\n\n---\n\n## Installation\n\n### Prerequisites\n\n- **Go 1.24+** - [Download Go](https://golang.org/dl/)\n- **Database Tools** (for the databases you want to backup):\n  - MySQL: `mysqldump`, `mysql` client\n  - PostgreSQL: `pg_dump`, `pg_restore`, `psql` client\n  - MongoDB: `mongodump`, `mongorestore` (MongoDB Database Tools)\n  - SQLite: Built-in (no external tools needed)\n\n### Option 1: Build from Source\n\n**On Windows:**\n```bash\ngit clone https://github.com/zfhassaan/dbx.git\ncd dbx\ngo build -o dbx.exe main.go\n```\n\n**On Linux/Mac:**\n```bash\ngit clone https://github.com/zfhassaan/dbx.git\ncd dbx\ngo build -o dbx main.go\n```\n\n### Option 2: Cross-Compile for Multiple Platforms\n\n**Using Makefile (Linux/Mac):**\n```bash\nmake build-all          # Build for Windows, Linux, and Linux ARM64\nmake build-windows      # Build Windows executable only\nmake build-linux        # Build Linux executable only\nmake build-linux-arm64 # Build Linux ARM64 executable\n```\n\n**Using Build Scripts:**\n\n**Windows:**\n```cmd\nbuild.bat\n```\n\n**Linux/Mac:**\n```bash\nchmod +x build.sh\n./build.sh\n```\n\n**Manual Cross-Compilation:**\n```bash\n# Windows executable\nGOOS=windows GOARCH=amd64 go build -o dist/dbx-windows-amd64.exe main.go\n\n# Linux executable\nGOOS=linux GOARCH=amd64 go build -o dist/dbx-linux-amd64 main.go\n\n# Linux ARM64 (for ARM servers)\nGOOS=linux GOARCH=arm64 go build -o dist/dbx-linux-arm64 main.go\n```\n\nAll executables will be created in the `dist/` directory.\n\n---\n\n## Usage\n\n### Interactive Menu\n\nRun without arguments to launch the interactive menu:\n\n```bash\n./dbx\n# or\n./dbx.exe\n```\n\nThe menu provides:\n- Database backup options (MySQL, PostgreSQL, MongoDB, SQLite)\n- Restore operations\n- Connection testing\n- Backup scheduling\n- Log viewing\n- Cloud storage help\n\n### Command-Line Interface\n\n#### Backup Commands\n\n**MySQL Backup:**\n```bash\ndbx backup mysql --host localhost --user root --password secret --database mydb --out ./backups --type full\n```\n\n**PostgreSQL Backup:**\n```bash\ndbx backup postgres --host localhost --port 5432 --user postgres --password secret --database mydb --out ./backups --type incremental\n```\n\n**MongoDB Backup:**\n```bash\ndbx backup mongo --uri mongodb://localhost:27017 --database mydb --out ./backups\n```\n\n**SQLite Backup:**\n```bash\ndbx backup sqlite --path /path/to/database.db --out ./backups\n```\n\n#### Restore Commands\n\n**MySQL Restore:**\n```bash\ndbx restore mysql --host localhost --user root --password secret --database mydb --file ./backups/backup.sql\n\n# Restore specific table\ndbx restore mysql --host localhost --user root --password secret --database mydb --file ./backups/backup.sql --table users\n```\n\n**PostgreSQL Restore:**\n```bash\ndbx restore postgres --host localhost --port 5432 --user postgres --password secret --database mydb --file ./backups/backup.dump\n\n# Restore specific table\ndbx restore postgres --host localhost --port 5432 --user postgres --password secret --database mydb --file ./backups/backup.dump --table users\n```\n\n**MongoDB Restore:**\n```bash\ndbx restore mongo --uri mongodb://localhost:27017 --database mydb --file ./backups/mydb_backup\n\n# Restore specific collection\ndbx restore mongo --uri mongodb://localhost:27017 --database mydb --file ./backups/mydb_backup --collection users\n```\n\n**SQLite Restore:**\n```bash\ndbx restore sqlite --path /path/to/restored.db --file ./backups/backup.db\n```\n\n#### Scheduling Commands\n\n**Add Scheduled Backup:**\n```bash\ndbx schedule add --db mysql --host localhost --user root --password secret --database mydb --out ./backups --cron \"0 2 * * *\"\n```\n\n**List Scheduled Backups:**\n```bash\ndbx schedule list\n```\n\n**Cron Examples:**\n- `0 2 * * *` - Daily at 2 AM\n- `0 */6 * * *` - Every 6 hours\n- `0 0 * * 0` - Weekly on Sunday at midnight\n- `0 0 1 * *` - Monthly on the 1st at midnight\n\n#### Help\n\nGet help for any command:\n```bash\ndbx --help\ndbx backup --help\ndbx backup mysql --help\ndbx restore --help\ndbx schedule --help\n```\n\n---\n\n## Cloud Storage Setup\n\n### AWS S3\n\n1. Install AWS CLI: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html\n2. Configure credentials:\n   ```bash\n   aws configure\n   ```\n3. Upload backups:\n   - Use the interactive menu and select \"Upload to AWS S3\" after backup\n   - Or set environment variables:\n     ```bash\n     export DBX_S3_BUCKET=my-backup-bucket\n     export DBX_S3_PREFIX=dbx/\n     ```\n\n### Google Cloud Storage\n\n1. Install Google Cloud SDK: https://cloud.google.com/sdk/docs/install\n2. Authenticate:\n   ```bash\n   gcloud auth login\n   ```\n3. Upload backups using the interactive menu\n\n### Azure Blob Storage\n\n1. Install Azure CLI: https://docs.microsoft.com/cli/azure/install-azure-cli\n2. Authenticate:\n   ```bash\n   az login\n   ```\n3. Upload backups using the interactive menu\n\n---\n\n## Notifications\n\n### Slack Integration\n\nAdd your Slack webhook URL to environment variables:\n\n```bash\nexport SLACK_WEBHOOK=https://hooks.slack.com/services/YOUR/WEBHOOK/URL\n```\n\nOr create a `.env` file:\n```\nSLACK_WEBHOOK=https://hooks.slack.com/services/YOUR/WEBHOOK/URL\n```\n\nBackup operations will automatically send notifications to Slack with:\n- Backup status (SUCCESS/FAILED)\n- Database name\n- Duration\n- Host and user information\n- Error details (if any)\n\n---\n\n## Testing\n\n### Run All Tests\n\n```bash\nmake test\n# or\ngo run scripts/runtests/main.go\n```\n\n### Run Tests for Specific Module\n\n```bash\ngo test -v ./tests/internal/db\ngo test -v ./tests/internal/cloud\ngo test -v ./tests/internal/scheduler\n```\n\n### Test Coverage\n\n```bash\nmake coverage\n# or\ngo run scripts/coverage/main.go\n```\n\n### Current Test Coverage\n\n- **cloud**: 20.0% coverage\n- **db**: 42.4% coverage\n- **logs**: 95.2% coverage\n- **notify**: 100.0% coverage\n- **scheduler**: 61.1% coverage\n- **utils**: 83.1% coverage\n\n**Total**: 110+ tests passing across all modules\n\n---\n\n## Security \u0026 Performance\n\n### Security\n- **Password Hiding**: Secure password input using `golang.org/x/term`\n- **Environment Variables**: Credentials stored in environment variables, not in code\n- **No Plaintext Storage**: Passwords never stored in plaintext\n- **Secure File Permissions**: Log files and configs use appropriate permissions\n\n### Performance\n- **Native Tools**: Uses native database tools (`mysqldump`, `pg_dump`, etc.) for optimal performance\n- **Streaming Compression**: Low memory footprint with streaming compression\n- **Efficient Scheduling**: Lightweight cron-based scheduler\n- **Parallel Operations**: Supports concurrent backup operations\n\n---\n\n## Configuration\n\n### Log Directory\n\nSet custom log directory:\n```bash\nexport DBX_LOG_DIR=/var/log/dbx\n```\n\nDefault: `./logs`\n\n### Scheduled Backups\n\nScheduled backups are stored in `config/schedules.json`. This file is automatically created and managed by the scheduler.\n\n---\n\n## Troubleshooting\n\n### Database Tools Not Found\n\nIf you see errors about missing database tools:\n\n**MySQL:**\n```bash\n# Ubuntu/Debian\nsudo apt install mysql-client\n\n# macOS\nbrew install mysql-client\n\n# Windows\n# Download MySQL Installer from mysql.com\n```\n\n**PostgreSQL:**\n```bash\n# Ubuntu/Debian\nsudo apt install postgresql-client\n\n# macOS\nbrew install postgresql\n\n# Windows\n# Download from postgresql.org\n```\n\n**MongoDB:**\n```bash\n# Ubuntu/Debian\nsudo apt install mongodb-database-tools\n\n# macOS\nbrew install mongodb-database-tools\n\n# Windows\n# Download MongoDB Tools from mongodb.com\n```\n\n### Permission Errors\n\nEnsure you have:\n- Read access to source databases\n- Write access to backup directories\n- Execute permissions for database tools\n\n### Cloud Upload Failures\n\n- Verify CLI tools are installed and configured\n- Check credentials and permissions\n- Ensure bucket/container names are correct\n- Verify network connectivity\n\n---\n\n## TODO\n\n- [ ] Add web-based dashboard for backup logs\n- [ ] Add encryption for backup files\n- [ ] Support for differential backup in MongoDB\n- [ ] Retry failed backups automatically\n- [ ] Add backup verification/checksum\n- [ ] Support for backup retention policies\n- [ ] Add email notifications\n\n---\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n### Development Setup\n\n```bash\n# Clone repository\ngit clone https://github.com/zfhassaan/dbx.git\ncd dbx\n\n# Install dependencies\ngo mod download\n\n# Run tests\nmake test\n\n# Check coverage\nmake coverage\n\n# Build\nmake build\n```\n\n---\n\n## License\n\nMIT License — feel free to fork and contribute!\n\nSee [LICENSE](LICENSE) file for details.\n\n---\n\n## Documentation\n\n- [CHANGELOG.md](CHANGELOG.md) - Version history\n- [TEST_COVERAGE.md](TEST_COVERAGE.md) - Test coverage details\n- [TEST_RUNNER.md](TEST_RUNNER.md) - Test runner documentation\n- [TEST_SUMMARY.md](TEST_SUMMARY.md) - Test suite summary\n\n---\n\n## Contributors\n\nBuilt by [zfhassaan](https://github.com/zfhassaan) — PRs welcome!\n\n---\n\n## Links\n\n- **Project URL**: https://roadmap.sh/projects/database-backup-utility\n- **GitHub Repository**: https://github.com/zfhassaan/dbx\n- **Releases**: https://github.com/zfhassaan/dbx/releases\n\n---\n\n## Version\n\nCurrent version: **v0.2.0**\n\nFor version history, see [CHANGELOG.md](CHANGELOG.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzfhassaan%2Fdbx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzfhassaan%2Fdbx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzfhassaan%2Fdbx/lists"}