Skip to content

Commit

Permalink
Initial version of Readme.
Browse files Browse the repository at this point in the history
Example of config file has been created, and also a requirements file.
  • Loading branch information
yakob-aleksandrovich committed Jul 9, 2024
1 parent 38fe122 commit cdf6fcc
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Introduction
This is a simple Python script to back up databases.
Right now, it only backs up MySQL databases, but _'maybe maybe'_ in the future
we might want to extend to RPM and Postgres as well.

## How it works
It is **assumed** that a configuration file `/etc/dbbackupr2.conf` exists.
An example of the file can be found in this repo as `dbbackupr2.conf`

The script makes a list of all databases existing on the MySQL host, does a
`mysqldump` per database, and then makes it into a bzip2 archive, to save space.
The resulting files, that look like `myql-my_database-2024-07-09.bz2`,
are stored in `BACKUP_DIR`.

Old database backups are retained for `MYSQL_KEEP_DAYS` days.

It is **assumed** that `mysqldump` and `bzip2` are available on the sytem.
No checks are done, so the script simply raises a gory Exception when
these CLI tools cannot be found.

It is also **assumed** that the MySQL connnection has already been defined
via the file ~/.my.cnf:
```ini
[client]
host=<mysql hostname>
user=<mysql username>
password=<mysql password>
default-character-set = utf8mb4
```

## Builds
This script is being built into a binary with the help of [pyinstaller](https://pyinstaller.org/en/stable/),

Running pyinstaller, when a `.venv` has been created.
```
pyinstaller --onefile --paths=.venv/lib/python3.10/site-packages dbbackupr2.py
```
2 changes: 2 additions & 0 deletions dbbackupr2.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BACKUP_DIR=/home/my-user/dbbackup
MYSQL_KEEP_DAYS=30
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python-dotenv==1.0.1

0 comments on commit cdf6fcc

Please sign in to comment.