Production-ready automated backup solution with support for multiple databases and multiple upload destinations.
- ✅ MySQL - Full mysqldump with routines, triggers, events
- ✅ PostgreSQL - pg_dump with custom format and SSL support
- ✅ MongoDB - mongodump with gzip and authentication
- ✅ Multiple Connections - Backup multiple databases with different schedules
- ✅ Local Storage - Always enabled
- ✅ Google Drive - OAuth2 integration
- ✅ AWS S3 - With pagination support for large buckets
- ✅ Azure Blob Storage - Full SDK integration
- ✅ SFTP/SCP - Password or private key authentication
- ✅ Telegram - Notifications and file uploads
- ✅ Parallel Uploads - All destinations upload simultaneously with retry
- ✅ Gzip - Standard compression (default)
- ✅ Zstandard - Better ratio, fast compression
- ✅ LZ4 - Ultra-fast compression
- ✅ AES-256-GCM - Optional backup encryption
- ✅ Prometheus Metrics - backup_duration, backup_size, success/failure counts
- ✅ Web API -
/health,/status,/history,/trigger/:db,/metrics - ✅ Health Checks - Database and storage connectivity monitoring
- ✅ Email - SMTP with HTML templates
- ✅ Slack - Webhook integration
- ✅ Discord - Webhook integration
- ✅ Telegram - Bot notifications
- ✅ SHA256 Verification - Backup integrity checksums
- ✅ Retry with Backoff - Automatic upload retries
- ✅ Pre/Post Hooks - Custom shell scripts
- ✅ Retention Policy - Automatic cleanup per-target
- ✅ Restore Command - Restore backups to databases
- ✅ Graceful Shutdown - Proper cleanup
# Database clients
sudo apt install mysql-client postgresql-client mongodb-clients
# Or on macOS
brew install mysql-client postgresql mongodb-community# Clone repository
git clone https://github.com/semmidev/phylax
cd phylax
# Install dependencies
make deps
# Build
make build
# Install as service
sudo make installapp:
name: 'phylax'
port: 8089
log_level: 'info'
log_file: 'log/phylax/backup.log'
# Web API (optional)
api:
enabled: true
port: 8080
databases:
- name: 'production-mysql'
type: 'mysql'
host: 'localhost'
port: 3306
username: 'backup'
password: 'secret'
database: 'myapp'
enabled: true
schedule: '0 0 2 * * *' # 2 AM daily
timeout: 3600s
- name: 'analytics-postgres'
type: 'postgresql'
host: 'db.example.com'
port: 5432
username: 'postgres'
password: 'secret'
database: 'analytics'
ssl_mode: 'require'
enabled: true
schedule: '0 0 3 * * *'
- name: 'logs-mongodb'
type: 'mongodb'
host: 'mongo.example.com'
port: 27017
username: 'admin'
password: 'secret'
database: 'logs'
auth_database: 'admin'
enabled: true
schedule: '0 0 4 * * *'
backup:
retention_days: 14
compress: true
verify: true
retry_attempts: 3
compression:
algorithm: 'zstd' # gzip, zstd, lz4
level: 6
encryption:
enabled: true
algorithm: 'AES-256-GCM'
key_file: '/etc/phylax/encryption.key'
upload_targets:
- type: 'local'
enabled: true
path: '/var/backups/databases'
retention_days: 7
- type: 's3'
enabled: true
region: 'us-east-1'
bucket: 'company-backups'
access_key: 'AKIA...'
secret_key: '...'
prefix: 'databases/'
retention_days: 90
- type: 'azure'
enabled: true
account_name: 'mystorageaccount'
account_key: '...'
container_name: 'backups'
- type: 'sftp'
enabled: true
sftp_host: 'backup.example.com'
sftp_port: 22
sftp_username: 'backup'
sftp_private_key: '/etc/phylax/sftp.key'
sftp_remote_path: '/backups'
notifications:
email:
enabled: true
smtp_host: 'smtp.gmail.com'
smtp_port: 587
username: 'alerts@company.com'
password: '...'
from: 'backups@company.com'
recipients: ['ops@company.com']
on_failure: true
slack:
enabled: true
webhook_url: 'https://hooks.slack.com/...'
channel: '#backup-alerts'
on_success: true
on_failure: true# Start service
sudo systemctl start phylax
# Enable on boot
sudo systemctl enable phylax
# Check status
sudo systemctl status phylax
# View logs
sudo journalctl -u phylax -f# Health check
curl http://localhost:8080/health
# Get status
curl http://localhost:8080/status
# View backup history
curl http://localhost:8080/history
# Trigger manual backup
curl -X POST http://localhost:8080/trigger/production-mysql
# Prometheus metrics
curl http://localhost:8080/metrics# Restore a backup
phylax-restore \
--file /var/backups/databases/mydb_mysql_20240115_020000.sql.gz \
--database production-mysql \
--config /etc/phylax/config.yaml
# Dry run (simulate)
phylax-restore --file backup.sql.gz --database mydb --dry-run┌─────────────────────────────────────────────────────────────┐
│ Scheduled Triggers │
│ 2 AM: MySQL | 3 AM: PostgreSQL | 4 AM: MongoDB │
└──────────────┬──────────────────┬──────────────────┬─────────┘
│ │ │
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Backup │ │ Backup │ │ Backup │
│ MySQL │ │PostgreSQL│ │ MongoDB │
└─────┬────┘ └─────┬────┘ └─────┬────┘
│ │ │
▼ ▼ ▼
[Compress: gzip/zstd/lz4] + [Encrypt: AES-256-GCM]
│ │ │
└──────────────────┴──────────────────┘
│
┌───────────┴───────────┐
│ Parallel Uploads │
│ (with retry logic) │
└───────────┬───────────┘
│
┌──────────┬──────────┬──────────┬──────────┬──────────┐
│ Local │ S3 │ Azure │ GDrive │ SFTP │
└────┬─────┴────┬─────┴────┬─────┴────┬─────┴────┬─────┘
└──────────┴──────────┴──────────┴──────────┘
│
┌───────────┴───────────┐
│ Notifications │
│ Email | Slack | Discord│
└───────────────────────┘
- Database passwords use environment variables (not command-line args)
- Config file should have restricted permissions (
chmod 600)
# Generate encryption key
openssl rand -base64 32 > /etc/phylax/encryption.key
chmod 600 /etc/phylax/encryption.key-- MySQL: Create dedicated backup user
CREATE USER 'backup'@'%' IDENTIFIED BY 'secure_password';
GRANT SELECT, LOCK TABLES, SHOW VIEW, EVENT, TRIGGER ON *.* TO 'backup'@'%';
-- PostgreSQL
CREATE USER backup WITH PASSWORD 'secure_password';
GRANT CONNECT ON DATABASE mydb TO backup;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO backup;Prometheus metrics available at /metrics:
| Metric | Description |
|---|---|
phylax_backup_duration_seconds |
Backup duration histogram |
phylax_backup_size_bytes |
Backup file size |
phylax_backup_success_total |
Successful backup counter |
phylax_backup_failure_total |
Failed backup counter |
phylax_upload_duration_seconds |
Upload duration histogram |
phylax_upload_success_total |
Successful upload counter |
phylax_upload_failure_total |
Failed upload counter |
phylax_last_backup_timestamp |
Last successful backup time |
# Run all tests
make test
# With coverage
go test -v -cover ./...Contributions welcome! Please ensure:
- Tests pass:
make test - Code formatted:
go fmt ./... - Linting clean:
golangci-lint run
MIT License - see LICENSE file
Built with:
- robfig/cron - Cron scheduler
- spf13/viper - Configuration
- uber-go/zap - Logging
- aws-sdk-go-v2 - AWS integration
- azure-sdk-for-go - Azure integration
- telegram-bot-api - Telegram
- prometheus/client_golang - Metrics
- klauspost/compress - Zstd compression
- pierrec/lz4 - LZ4 compression
Made with ❤️ for reliable database backups