https://github.com/alilotfi23/dbcapsule
This command-line tool allows you to back up MySQL and PostgreSQL databases easily using Python and Typer.
https://github.com/alilotfi23/dbcapsule
mysql postgres postgresql python typer
Last synced: about 2 months ago
JSON representation
This command-line tool allows you to back up MySQL and PostgreSQL databases easily using Python and Typer.
- Host: GitHub
- URL: https://github.com/alilotfi23/dbcapsule
- Owner: alilotfi23
- License: mit
- Created: 2024-07-03T09:01:11.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-30T10:19:04.000Z (over 1 year ago)
- Last Synced: 2025-04-06T14:15:20.538Z (about 1 year ago)
- Topics: mysql, postgres, postgresql, python, typer
- Language: Python
- Homepage:
- Size: 33.2 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Database Backup Tool
This command-line tool allows you to back up MySQL and PostgreSQL databases using Python and Typer.
## Features
- **Backup MySQL or PostgreSQL databases**
- **Backup all databases or a single database**
- **Dumps only the definitions of tablespaces no databases or roles (PostgreSQL)**
- **Dumps only the schema no data (PostgreSQL)**
- **Specify custom backup path**
## Prerequisites
- Python 3.x installed
- Required Python packages (`typer`, `pathlib`)
- MySQL (`mysqldump`) or PostgreSQL (`pg_dump`, `pg_dumpall`) command-line tools installed and accessible from the terminal
## Installation
1. Clone the repository:
```bash
git clone https://github.com/alilotfi23/DBCapsule.git
cd DBCapsule
```
2. Install dependencies:
```bash
pip install -r requirements.txt
```
## Usage
### Command Syntax
```bash
python dbcapsule.py backup [OPTIONS]
```
### Options
- `--db-type`: Specify the type of database (`mysql` or `postgres`).
- `--all`: Backup all databases
- `--single `: Backup a single database by name.
- `--path `: Path to store the backup file.
### Examples
1. **Backup all MySQL databases**:
```bash
python dbcapsule.py --db-type mysql --all --path /path/to/your/backup/folder
```
2. **Backup single MySQL databases**:
```bash
python dbcapsule.py --db-type mysql --single your_database_name --path /path/to/your/backup/folder
```
3. **Backup all PostgreSQL database**:
```bash
python dbcapsule.py --db-type postgres --all --path /path/to/your/backup/folder
```
4. **Backup a single PostgreSQL database**:
```bash
python dbcapsule.py --db-type postgres --single your_database_name --path /path/to/your/backup/folder
```
5. **Backup only the tablespaces of a single PostgreSQL database**:
```bash
python dbcapsule.py backup --db-type postgres --single mydatabase --tablespaces --path /path/to/backup
```
6. **Backup only the schema of a single PostgreSQL database**:
```bash
python dbcapsule.py backup --db-type postgres --single mydatabase --schema --path /path/to/backup
```
## Notes
- Could you make sure to provide correct database credentials when prompted?
- Ensure the specified backup path exists or allow the tool to create it.