Skip to main content

Simple package for backups and recovery

Project description

PatronX

PatronX is a small toolkit for managing PostgreSQL backups and point‑in‑time restores. It is written in typed Python and exposes a concise command‑line interface. Backups can be scheduled, diffed and off‑loaded to S3 with a minimal setup.

codecov Test Docker publish PyPI publish PyPI

Docker Tags are available on Docker Hub:

Utilities

Command Purpose
patronx backup create a new dump
patronx restore restore a dump into the database
patronx list list all dumps in BACKUP_DIR
patronx diff diff latest dump against the database
patronx check-db verify database connectivity
patronx start run scheduled backup/cleanup loops and listen for healthcheck
patronx enqueue-backup queue a backup job immediately
patronx enqueue-cleanup queue cleanup of old dumps

backup and enqueue-backup upload the dumps to s3 if s3 is configured.

Configuration

The following environment variables control how PatronX connects to the database and schedules jobs:

  • PGHOST – database host (default localhost)
  • PGPORT – database port (default 5432)
  • PGUSER – authentication user (default test_user)
  • PGPASSWORD – password for PGUSER
  • PGDATABASE – database name (default test_db)
  • BACKUP_DIR – where dumps are stored (default ./backups)
  • BACKUP_CRON – cron expression for automated backups
  • CLEANUP_CRON – cron expression for removing old dumps
  • RETENTION_DAYS – how long to keep dumps (default 30)
  • S3_BUCKET – optional bucket for S3 uploads
  • AMQP_URL – RabbitMQ connection string
  • LOGSTASH_HOST – Logstash host (default logstash)
  • LOGSTASH_PORT – Logstash port (default 5000)
  • HEALTH_PORT – port for the built‑in health server (default 7775)

Docs

For guidance on setting up an IAM user with minimum access for S3 uploads, see docs/aws-user-creation.md.

Development

pytest                   # run tests
ruff check . --fix       # lint
isort .                  # format imports

generate requirements.txt

pip install pip-tools
pip-compile --output-file=requirements.txt pyproject.toml 

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

patronx-2.4.0.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

patronx-2.4.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file patronx-2.4.0.tar.gz.

File metadata

  • Download URL: patronx-2.4.0.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for patronx-2.4.0.tar.gz
Algorithm Hash digest
SHA256 a6ece4d0dcda81715df1a393ec98282e44f3a2f060d2f4a7dbc1c63e17f9f18a
MD5 8bace1def8bee43be91e020dc0f16afe
BLAKE2b-256 b727fdc1dea23528a0ae95f980f9a41b681e84ad1fa424480f3e674ce223f192

See more details on using hashes here.

Provenance

The following attestation bundles were made for patronx-2.4.0.tar.gz:

Publisher: cd-publish-to-pypi.yml on xdanielsb/patronx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file patronx-2.4.0-py3-none-any.whl.

File metadata

  • Download URL: patronx-2.4.0-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for patronx-2.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e694923e241b1ca1c3c10722f84f80a4c0d062376524cab35ad9e0d793629224
MD5 c606a7b24c0d5e7ca1b3386a769fdfab
BLAKE2b-256 d31ccc06e00e0156d207c043cbc24ff43477d69d659fd89ae8e6587280857bda

See more details on using hashes here.

Provenance

The following attestation bundles were made for patronx-2.4.0-py3-none-any.whl:

Publisher: cd-publish-to-pypi.yml on xdanielsb/patronx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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