A simple and efficient command-line interface (CLI) tool for managing database backups and restores. This tool supports PostgreSQL and MySQL databases, and allows you to store backups in an S3-compatible storage like MinIO.
- Backup & Restore: Easily back up and restore databases (PostgreSQL, MySQL).
- S3 Integration: Store backups in MinIO (or any S3-compatible storage).
- Configuration Options: Use command-line options or a YAML configuration file.
- Error Handling: Handles common errors with helpful error messages.
- Custom Port Support: Specify custom database ports for flexibility.
- Flexible Input: Provide database details through CLI options or configuration file.
- Python 3.7+
- PostgreSQL or MySQL client tools
- MinIO or any S3-compatible storage for remote backup storage
-
Clone this repository:
git clone https://github.com/Swim-to-the-goal/db-backup-cli.git cd db-backup-cli
-
Install dependencies:
pip install -r requirements.txt
You can configure the CLI either through command-line options or by creating a YAML configuration file.
database:
type: "postgresql" # Options: "postgresql" or "mysql"
host: "localhost"
port: 5432 # Default: 5432 for PostgreSQL, 3306 for MySQL
user: "your_user"
password: "your_password"
database: "your_database"
s3:
endpoint: "localhost:9000"
access_key: "minio-access-key"
secret_key: "minio-secret-key"
backup_bucket_name: "backup-bucket"
restore_bucket_name: "restore-bucket"
python main.py backup --config-path config.yaml
Or provide details directly via CLI:
python main.py backup --db-type postgresql --host localhost --port 5432 --user your_user --password your_password --database your_database
python main.py restore <backup_file_name> --config-path config.yaml
Or provide details directly via CLI:
python main.py restore <backup_file_name> --db-type postgresql --host localhost --port 5432 --user your_user --password your_password --database your_database
python main.py backup --db-type mysql --host 127.0.0.1 --port 3306 --user root --password root_password --database my_database
python main.py restore my_database_backup.sql --config-path config.yaml
- Add encryption for backup files
- Support additional databases (e.g., MongoDB, Oracle)
- Integrate with Docker for easy deployment
- Add scheduling functionality
Contributions are welcome! Please open an issue to discuss your idea or submit a pull request.