Metadata-Version: 2.4
Name: patronx
Version: 2.0.0
Summary: Simple package for backups and recovery
Author: xdanielsb
License: BSD-3-Clause
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: click>=8.0
Requires-Dist: psycopg2-binary>=2.9
Requires-Dist: tqdm
Requires-Dist: boto3>=1.34
Requires-Dist: remoulade[rabbitmq]==3.3.1
Requires-Dist: croniter>=6.0
Requires-Dist: python-dotenv>=1.0
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Requires-Dist: ruff; extra == "test"
Requires-Dist: isort; extra == "test"
Requires-Dist: mypy; extra == "test"
Dynamic: license-file

# PatronX

PatronX is a lightweight toolkit for PostgreSQL backups, point‑in‑time recovery
and object‑storage offloading. The project is written in modern typed Python
and ships with a clean command‑line interface.

<img src="./patronx.jpg" width="200" />

[![codecov](https://codecov.io/gh/xdanielsb/patron/graph/badge.svg?token=AHTJFKDSKU)](https://codecov.io/gh/xdanielsb/patron)
![Test](https://github.com/xdanielsb/patron/actions/workflows/ci-test.yml/badge.svg)
![Docker publish](https://github.com/xdanielsb/patronx/actions/workflows/cd-docker-publish.yml/badge.svg)
![PyPI publish](https://github.com/xdanielsb/patronx/actions/workflows/cd-publish-to-pypi.yml/badge.svg)
[![PyPI](https://img.shields.io/pypi/v/patronx)](https://pypi.org/project/patronx/)

## Features

- Simple CLI for backup, restore and listing available dumps
- Scheduled backups via cron expressions
- Optional upload to S3 for off‑site storage
- Typed Python code with unit tests

## DB
- postgres >= 16

```bash
pip install -e . # to install in editable mode
patronx --version
patronx list
patronx check-db
patronx backup [--plain] [--no-progress]
patronx restore --inp /path/to/backup.dump [--plain] [--no-progress]
patronx server

patronx enqueue-backup # with remoulade and rabbitmq
```

The server command starts schedulers that enqueue backup and cleanup jobs
periodically. The backup schedule is controlled via the ``BACKUP_CRON``
environment variable while cleanup uses ``CLEANUP_CRON``. Both take standard
cron expressions. When unset they default to running once per day for backups
and at 1AM for cleanup. Old backups are removed according to the number of days
specified in ``RETENTION_DAYS`` (defaults to ``30``).


### AWS configuration
Set the following variables so ``AwsAssetStore`` can authenticate using the
``s3-uploader-luxoai`` IAM user:

``AWS_ACCESS_KEY_ID``
    Access key for the IAM user.
``AWS_SECRET_ACCESS_KEY``
    Secret key for the IAM user.
``AWS_REGION``
    Region where the bucket resides.

### Test
```bash
pytest
```

### Linting and Formatting
```bash
ruff check . --fix
isort .
```


### Generate requirements
```bash
pip install pip-tools
pip-compile --output-file=requirements.txt pyproject.toml
```
