Skip to content

Backup MySQL, MariaDB or PostgreSQL databases from Docker to Telegram chat

Notifications You must be signed in to change notification settings

kanewi11/db-telegram-backup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DB Telegram Backup

A Python-based solution to backup data via Telegram with an easy setup process and periodic task scheduling using crontab.

Supported databases

  • PostgreSQL
  • MySQL
  • MariaDB

Installation

Follow the steps below to install the project:

  1. Navigate to the /opt directory:
    cd /opt
  2. Clone the repository:
    sudo git clone https://github.com/kanewi11/db-telegram-backup.git
  3. Enter the project directory:
    cd /opt/db-telegram-backup
  4. Update the package list and install Python pip:
    sudo apt-get update -y && sudo apt-get install python3-pip -y
  5. Install Poetry (Python dependency manager):
    curl -sSL https://install.python-poetry.org | python3 -
  6. Add Poetry to the system path:
    export PATH="$HOME/.local/bin:$PATH"
  7. Configure Poetry to use project-local virtual environments:
    sudo poetry config virtualenvs.in-project true
  8. Install the project dependencies using Poetry:
    sudo poetry install

Setting Up Before Starting

Prepare the environment and perform a functional check:

  1. Navigate to the project directory:
    cd /opt/db-telegram-backup
  2. Create a .env file from the example template:
    sudo cp .envs/.env.example .envs/.env
  3. Open the .env file for editing:
    sudo nano .envs/.env
  4. Activate the virtual environment:
    sudo poetry shell
  5. Run the main script to verify functionality:
    sudo python main.py

Automating with Crontab

Set up a cron job to automate the backup process:

  1. Open the crontab editor:
    sudo crontab -e
  2. Add the following line to schedule the script to run hourly:
    0 * * * * cd /opt/db-telegram-backup/ && .venv/bin/python main.py
    
    This runs the script at the start of every hour.

Contributing

Feel free to contribute by submitting issues or pull requests to the GitHub repository. I won't answer or respond to them anyway :)

About

Backup MySQL, MariaDB or PostgreSQL databases from Docker to Telegram chat

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages