borg-backup-ui icon indicating copy to clipboard operation
borg-backup-ui copied to clipboard

Add backup and restore-test lifecycle summaries before beta

Open borg-codex-bot opened this issue 4 months ago • 2 comments

Context

The application log currently shows when /api/jobs/run was called, but it does not provide a compact lifecycle view of what happened afterwards. Detailed backup and restore-test logs exist separately, but the main application log should still tell support where the run started, which process/log file belongs to it, how it ended, and which notification profiles were involved.

Without lifecycle summaries, a tester often needs to provide multiple files before maintainers can even identify the relevant run.

Goal

Add concise lifecycle summary lines for backups and restore tests so the main application log can guide support to the right detail log and final status.

Scope

For backup jobs, log these stages in the application log or a clearly included support log:

  • JOB requested
    • request id when triggered by API/UI
    • job key
    • source such as manual, schedule or API
    • actor where safe
  • JOB process_started
    • job key
    • PID
    • log file path
    • status file path where available
  • JOB finished
    • job key
    • result status: success, warning, failed, skipped or cancelled
    • exit code
    • duration
    • log file path
    • status file path
    • failure code or short sanitized reason when applicable
  • JOB notification
    • event type
    • delivery mode, such as sync or queued
    • delivered Apprise profile names/ids
    • skipped/missing profile reason where relevant

For restore tests, log equivalent stages:

  • RESTORE_TEST requested or scheduled start
  • RESTORE_TEST process_started
  • RESTORE_TEST finished
  • RESTORE_TEST notification

The lifecycle summary should cover both manually triggered and scheduled runs where possible.

Acceptance criteria

  • A manually started backup can be followed in the main/support log from request to process start to final result.
  • A scheduled backup can be followed even when there is no UI request id.
  • The summary includes the detail log path for each run.
  • The final line includes status, exit code and duration.
  • Skipped, cancelled and failed runs include a short sanitized reason or failure code.
  • Restore-test runs have equivalent start/process/finish summary lines.
  • Apprise notification delivery for run events is summarized with event type and delivered profile names/ids without secrets.
  • The implementation does not duplicate full Borg output into the application log. The detailed Borg output stays in the run log.
  • Tests cover successful, warning, failed, skipped and cancelled backup summaries where practical, plus at least one restore-test summary path.

Suggested implementation

  • Add a small lifecycle logging helper that emits stable key-value lines.
  • Integrate it into the job runner path around /api/jobs/run, api/wizard_runner.py and runtime/lib/backup_job.py.
  • Integrate equivalent summary hooks into runtime/scripts/borg_restore_test.py.
  • Reuse existing notification event results so notification summaries do not invent a second delivery model.
  • Make sure log lines are safe for support bundles and do not expose Borg passphrases, Apprise URLs, tokens or passwords.

Example target lines

JOB requested request_id=... source=manual job_key=appdata_local
JOB process_started job_key=appdata_local pid=12345 log_file=/mnt/user/Logs/Borg-appdata-local--2026-07-22_09-00-01.log
JOB finished job_key=appdata_local status=success exit_code=0 duration_seconds=384 log_file=/mnt/user/Logs/Borg-appdata-local--2026-07-22_09-00-01.log
JOB notification job_key=appdata_local event=backup_success apprise=true apprise_mode=queued apprise_profiles=["Borg-Backup-UI (ntfy-migrated)"]

Notes

This is stage 3 of the pre-beta support logging work. Stage 1 reduces routine noise, stage 2 enriches action context, and this stage makes actual backup/restore execution diagnosable from the main support log.

borg-codex-bot avatar Jul 22 '26 10:07 borg-codex-bot

Implemented in draft PR #275.

Summary:

  • Added compact JOB and RESTORE_TEST lifecycle lines for requested, process_started, finished and notification stages.
  • Propagated request_id, source and actor context into backup and restore-test subprocesses, including scheduled jobs.
  • Added notification lifecycle summaries with Apprise delivery mode and delivered profile names.
  • Published test-channel version 2026.07.22.1345 from commit 6c72f6e7df9dd120333f08d9a47f3b8f93d88ea7.

Verification:

  • Focused tests passed.
  • Full mr-preflight passed: 595 tests.
  • Test-channel snapshot contains exactly the manifest and one package.

borg-codex-bot avatar Jul 22 '26 11:07 borg-codex-bot

Closed via merged PR #274.

borg-codex-bot avatar Jul 22 '26 12:07 borg-codex-bot