A Python-based solution to backup data via Telegram with an easy setup process and periodic task scheduling using crontab
.
PostgreSQL
MySQL
MariaDB
Follow the steps below to install the project:
- Navigate to the
/opt
directory:cd /opt
- Clone the repository:
sudo git clone https://github.com/kanewi11/db-telegram-backup.git
- Enter the project directory:
cd /opt/db-telegram-backup
- Update the package list and install Python pip:
sudo apt-get update -y && sudo apt-get install python3-pip -y
- Install Poetry (Python dependency manager):
curl -sSL https://install.python-poetry.org | python3 -
- Add Poetry to the system path:
export PATH="$HOME/.local/bin:$PATH"
- Configure Poetry to use project-local virtual environments:
sudo poetry config virtualenvs.in-project true
- Install the project dependencies using Poetry:
sudo poetry install
Prepare the environment and perform a functional check:
- Navigate to the project directory:
cd /opt/db-telegram-backup
- Create a
.env
file from the example template:sudo cp .envs/.env.example .envs/.env
- Open the
.env
file for editing:sudo nano .envs/.env
- Activate the virtual environment:
sudo poetry shell
- Run the main script to verify functionality:
sudo python main.py
Set up a cron job to automate the backup process:
- Open the crontab editor:
sudo crontab -e
- Add the following line to schedule the script to run hourly:
This runs the script at the start of every hour.
0 * * * * cd /opt/db-telegram-backup/ && .venv/bin/python main.py
Feel free to contribute by submitting issues or pull requests to the GitHub repository. I won't answer or respond to them anyway :)