feat: make Django configs drive backups and scheduling

Treat SQL-backed Django models as the source of truth for pobsync
configuration, exporting runtime YAML only as a compatibility layer for
the existing engine. Add a database-driven scheduler command, Docker
scheduler services, schedule run-state fields, and tests for scheduler,
config export, and retention behavior.
This commit is contained in:
2026-05-19 04:53:47 +02:00
parent 1a51c3e448
commit 18082496e4
13 changed files with 493 additions and 13 deletions

View File

@@ -8,8 +8,8 @@ from django.core.management.base import BaseCommand, CommandError
from django.utils import timezone
from pobsync.commands.run_scheduled import run_scheduled
from pobsync.config.load import load_host_config
from pobsync.paths import PobsyncPaths
from pobsync_backend.config_repository import export_runtime_configs
from pobsync_backend.models import BackupRun, HostConfig
@@ -27,19 +27,12 @@ class Command(BaseCommand):
def handle(self, *args: Any, **options: Any) -> None:
host_name = options["host"]
paths = PobsyncPaths(home=Path(options["prefix"]))
host_path = paths.hosts_dir / f"{host_name}.yaml"
if not host_path.exists():
raise CommandError(f"Missing host config: {host_path}")
try:
host = HostConfig.objects.get(host=host_name, enabled=True)
except HostConfig.DoesNotExist as exc:
raise CommandError(f"Missing enabled HostConfig {host_name!r}") from exc
host_cfg = load_host_config(host_path)
host, _created = HostConfig.objects.update_or_create(
host=host_cfg["host"],
defaults={
"address": host_cfg["address"],
"config": host_cfg,
"enabled": True,
},
)
export_runtime_configs(prefix=paths.home, host=host.host)
run = BackupRun.objects.create(
host=host,