Skip to main content

Backup Utilities for Linux VPS with MySQL and other data

Project description

vps_backup_utils

Python 3 PyPI downloads

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)

Supported cli

  • mysqldump
  • pg_dump
  • tar
  • gzip
  • rsync (to remote servers)

Usage

  1. Run pip install vps_backup_utils on your VPS
  2. Write a Python script like the below one, and save on your VPS
  3. Add this script to your VPS's crontab
#!/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
)

develop

install dependencies

pip3 install poetry
poetry install

test on host machine

Write your codes to main.py, and just run.

python3 main.py

run unit tests on host machine (not recommended)

poetry run pytest

run unit tests on docker (recommended)

docker-compose up -d mysql postgresql
docker-compose up pytest --build

build & publish

poetry update && poetry build && poetry publish

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vps_backup_utils-0.0.3.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

vps_backup_utils-0.0.3-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page