feat: add Django backend foundation and Docker runtime

Add a Django admin-backed management layer for pobsync configs, runs,
snapshots, and schedules. Keep the existing CLI engine as the execution
source of truth, add import/run management commands, and provide SQLite
default plus optional MariaDB Docker Compose support.
This commit is contained in:
2026-05-19 04:48:13 +02:00
parent 27acd790bd
commit 1a51c3e448
23 changed files with 722 additions and 3 deletions

View File

@@ -100,9 +100,11 @@ Cron output is redirected to:
## Development (optional)
For development purposes you can still use an editable install, this is why pyproject.toml still exists:
For development purposes you can still use an editable install, this is why pyproject.toml still exists. On systems with an externally managed Python installation, create a virtualenv first.
```
python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install -e .
pobsync --help
```
@@ -110,3 +112,64 @@ pobsync --help
For production use, always use the canonical entrypoint:
/opt/pobsync/bin/pobsync
## Django backend (early refactor layer)
The Django backend is a management layer around the existing pobsync engine. The current CLI remains the source of truth for executing backups; Django stores configs, schedules, backup runs, and snapshot metadata so the project can grow toward a web/admin/API surface without rewriting rsync behavior in one risky step.
### Local SQLite development
```
python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install -e .
mkdir -p var
python3 manage.py migrate
python3 manage.py createsuperuser
python3 manage.py runserver
```
The admin is available at:
- http://127.0.0.1:8000/admin/
Import existing YAML configs into the database:
```
python3 manage.py import_pobsync_configs --prefix /opt/pobsync
```
Run a backup through Django while still using the existing pobsync engine:
```
python3 manage.py run_pobsync_backup <host> --prefix /opt/pobsync --prune
```
### Docker with SQLite
```
docker compose up --build web
```
This starts Django on:
- http://127.0.0.1:8000/admin/
The container persists `/opt/pobsync` and the SQLite database in Docker volumes.
### Docker with MariaDB
```
docker compose --profile mariadb up --build web-mariadb
```
The MariaDB profile is optional. SQLite remains the default because it is enough for a single backup server and keeps deployment simple.
### Refactor direction
Recommended next steps:
- Move config reading/writing behind a repository interface that can use YAML or Django models.
- Record `run-scheduled` results into `BackupRun`.
- Add a snapshot discovery command that syncs existing snapshot metadata into `SnapshotRecord`.
- Add tests around retention, scheduling, and config merge before deeper internal reshaping.