Plan: keep the nightly cleanup log and show it in the web UI

Hi all, and @uroni in particular,

I’m LJ, a fairly new UrBackup user (server in Docker, storage on a Synology over NFS). I’ve started sending small PRs: #154 runs the incomplete-backup sweep at startup as well as in the nightly window, and #155 is a few small web UI fixes from the Feature Requests category.

Next I’d like to take on Cleanup Log in GUI. Before writing code I want to check the approach.

Current behaviour, from reading the code: the cleanup thread logs through ServerLogger under LOG_CATEGORY_CLEANUP, but nothing ever saves that log. Backups call ServerLogger::getLogdata() and write the result to the logs table; cleanup doesn’t. So the cleanup log only exists in the live log while it runs, and in urbackup.log on the host, which is hard to reach on a NAS or in a container.

What I’d propose:

  1. Save the log of each cleanup run (nightly, emergency/min-space, and the new startup sweep) when it finishes, the same way backups do.
  2. Show those runs on the Logs page.
  3. Make the log say why: one short line per decision, e.g. “Deleting image backup 1234 of client X (exceeds max. 30 incremental images)” or “Keeping file backup 567: needed by 2 incrementals / archived / below min. count”.

Questions before I start:

  • logs rows are tied to a clientid. Would you rather store cleanup runs under a pseudo-client (e.g. clientid=0) and add a “Server” entry to the Logs client filter, or give them their own table/view?
  • Any concerns about log volume? A large server can decide about hundreds of backups per night. I could log only deletions at info level and “kept because…” at debug, so the saved log uses the configured log level.
  • Should this also go into the new www2 UI, or old UI only for now?

Thanks!

Looks like client code 0 wouldn’t work, but im thinking null would work and allow them to be shown as system

I went ahead and put the approach into a draft PR so there’s something concrete to look at: Save cleanup logs and show them on the Logs page by ljlongwing · Pull Request #156 · uroni/urbackup_backend · GitHub . It stores cleanup runs with clientid NULL and adds a “Server clean-up” entry to the Logs filter, visible only to users with rights to all logs. Each part is a separate commit, so it’s easy to change if you’d prefer a different design.