(bugfix) Guard dry-run logs and recursive rsync defaults

Clear the reused dry-run rsync log before each dry-run so run details
only show output from the current execution.

Populate new Django global configs with the existing safe rsync and
exclude defaults, including archive mode and standard pseudo-filesystem
exclusions.

Add a host check that fails when effective rsync args do not include
archive or recursive transfer, preventing real backups that only report
"skipping directory .".
This commit is contained in:
2026-05-19 20:09:35 +02:00
parent 8bd2a8ff1a
commit 7e5d31d53b
5 changed files with 61 additions and 0 deletions

View File

@@ -78,9 +78,31 @@ def collect_host_checks(host: HostConfig, global_config: GlobalConfig | None = N
checks.append(_host_path_check("Host backup root", host_root, must_exist=True, must_be_writable=True))
for subdir in HOST_BACKUP_SUBDIRS:
checks.append(_host_path_check(f"Host directory: {subdir}", host_root / subdir, must_exist=True, must_be_writable=True))
checks.append(_rsync_recursion_check(host, global_config))
return checks
def _rsync_recursion_check(host: HostConfig, global_config: GlobalConfig) -> SelfCheck:
args = [*list(global_config.rsync_args or []), *list(global_config.rsync_extra_args or []), *list(host.rsync_extra_args or [])]
if _has_recursive_rsync_arg(args):
return SelfCheck("Host rsync recursion", "ok", "Rsync args include archive or recursive transfer.", " ".join(args))
return SelfCheck(
"Host rsync recursion",
"failed",
"Rsync args do not include archive or recursive transfer.",
"Add --archive or --recursive before running a real backup.",
)
def _has_recursive_rsync_arg(args: list[str]) -> bool:
for arg in args:
if arg in {"--archive", "--recursive"}:
return True
if arg.startswith("-") and not arg.startswith("--") and any(flag in arg for flag in ("a", "r")):
return True
return False
def _host_path_check(
name: str,
path: Path,