Skip to content

This command-line tool allows you to back up MySQL and PostgreSQL databases easily using Python and Typer.

License

Notifications You must be signed in to change notification settings

alilotfi23/DBCapsule

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Database Backup Tool

This command-line tool allows you to back up MySQL and PostgreSQL databases easily 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:

    git clone https://github.com/alilotfi23/DBCapsule.git
    cd DBCapsule
  2. Install dependencies:

    pip install -r requirements.txt

Usage

Command Syntax

python dbcapsule.py backup [OPTIONS]

Options

  • --db-type: Specify the type of database (mysql or postgres).
  • --all: Backup all databases
  • --single <database_name>: Backup a single database by name.
  • --path <backup_path>: Path to store the backup file.

Examples

  1. Backup all MySQL databases:

    python dbcapsule.py --db-type mysql --all --path /path/to/your/backup/folder
  2. Backup single MySQL databases:

     python dbcapsule.py --db-type mysql --single your_database_name --path /path/to/your/backup/folder
  3. Backup a all PostgreSQL database:

     python dbcapsule.py --db-type postgres --all --path /path/to/your/backup/folder
  4. Backup a single PostgreSQL database:

    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:

    python dbcapsule.py backup --db-type postgres --single mydatabase --tablespaces --path /path/to/backup
  6. Backup only the schema of a single PostgreSQL database:

    python dbcapsule.py backup --db-type postgres --single mydatabase --schema --path /path/to/backup

Notes

  • Make sure to provide correct database credentials when prompted.
  • Ensure the specified backup path exists or allow the tool to create it.

About

This command-line tool allows you to back up MySQL and PostgreSQL databases easily using Python and Typer.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages