from __future__ import annotations import re from pathlib import Path ROOT = Path(__file__).resolve().parents[3] BACKUP_ALL = ROOT / "scripts" / "backup" / "backup-all.sh" PLAYBOOK = ROOT / "infra" / "ansible" / "playbooks" / "110-devops.yml" REQUIRED_BACKUP_SCRIPTS = ( "backup-gitea.sh", "backup-momo.sh", "backup-harbor.sh", "backup-awoooi.sh", "backup-langfuse.sh", "backup-monitoring.sh", "backup-signoz.sh", "backup-open-webui.sh", "backup-clawbot.sh", "backup-sentry.sh", "backup-ai-artifacts.sh", "backup-configs.sh", "backup-public-routes.sh", ) def test_backup_all_runs_every_required_domain_once() -> None: source = BACKUP_ALL.read_text(encoding="utf-8") assert "local total=13" in source assert [int(value) for value in re.findall(r">>> \[(\d+)/\$\{total\}\]", source)] == list( range(1, 14) ) for script in REQUIRED_BACKUP_SCRIPTS: assert source.count(f"/backup/scripts/{script}") == 1 def test_ansible_deploys_every_script_called_by_backup_all() -> None: playbook = PLAYBOOK.read_text(encoding="utf-8") for script in REQUIRED_BACKUP_SCRIPTS: assert f"- {script}" in playbook def test_backup_all_does_not_publish_or_delete_offsite_data() -> None: source = BACKUP_ALL.read_text(encoding="utf-8") for forbidden in ("rclone ", "sync-offsite-backups.sh", "rclone-last-success"): assert forbidden not in source