Backup Utilities for Linux VPS with MySQL and other data.
With this package, you can write Python scripts to call cli tools. (need to install cli tools in advance)
-
mysqldump
-
pg_dump
andpg_dumpall
-
tar
-
gzip
-
rsync
(to remote servers)
- Run
pip install vps_backup_utils
on your VPS - Write a Python script like the below one, and save on your VPS
- Add this script to your VPS's crontab (execute
crontab -e
, and append0 4 * * * /path/to/your/script.py
for example, which will run at 4:00 AM every day)
#!/usr/bin/env python
from vps_backup_utils import VPSBackupUtils
backuper = VPSBackupUtils('~/backup')
backuper.remove_old_backups(30)
backuper.mysqldump_backup(
backup_prefix='project1',
host='127.0.0.1',
port='3306',
user='root',
password='password',
databases=None,
gzipped=True
)
backuper.tar_backup(
backup_prefix='project1',
src_folder='/path/to/project1/data'
)
backuper.mysqldump_backup(
backup_prefix='another_project',
host='127.0.0.1',
port='3307',
user='root',
password='password',
databases=None,
gzipped=True
)
backuper.rsync_backups_to_remote(
host='another.server',
user='user',
remote_backup_path='~/server1-backup',
port='22222',
delete_mode=True
)
pip3 install poetry
poetry install
Write your scripts as main.py
, and just run it!
python3 main.py
poetry run pytest
docker-compose up -d mysql postgresql
docker-compose up pytest --build --force-recreate
poetry update && poetry build && poetry publish