This command-line tool allows you to back up MySQL and PostgreSQL databases easily using Python and Typer.
- 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
- 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
-
Clone the repository:
git clone https://github.com/alilotfi23/DBCapsule.git cd DBCapsule
-
Install dependencies:
pip install -r requirements.txt
python dbcapsule.py backup [OPTIONS]
--db-type
: Specify the type of database (mysql
orpostgres
).--all
: Backup all databases--single <database_name>
: Backup a single database by name.--path <backup_path>
: Path to store the backup file.
-
Backup all MySQL databases:
python dbcapsule.py --db-type mysql --all --path /path/to/your/backup/folder
-
Backup single MySQL databases:
python dbcapsule.py --db-type mysql --single your_database_name --path /path/to/your/backup/folder
-
Backup a all PostgreSQL database:
python dbcapsule.py --db-type postgres --all --path /path/to/your/backup/folder
-
Backup a single PostgreSQL database:
python dbcapsule.py --db-type postgres --single your_database_name --path /path/to/your/backup/folder
-
Backup only the tablespaces of a single PostgreSQL database:
python dbcapsule.py backup --db-type postgres --single mydatabase --tablespaces --path /path/to/backup
-
Backup only the schema of a single PostgreSQL database:
python dbcapsule.py backup --db-type postgres --single mydatabase --schema --path /path/to/backup
- Make sure to provide correct database credentials when prompted.
- Ensure the specified backup path exists or allow the tool to create it.