Files
computer-playbook/roles/sys-ctl-cln-bkps
Kevin Veen-Birkenbach 91ce097a0a feat(sys-service): migrate cleanup/backup services to generic units; harden disk-space cleanup
Services: add SYS_SERVICE_CLEANUP_BACKUPS and SYS_SERVICE_CLEANUP_DISC_SPACE in group vars.

sys-ctl-bkp-docker-2-loc: switch to sys-service; add ExecStartPre lock; ExecStartPost triggers backup cleanup; OnFailure → cleanup-failed; fix shell quoting.

sys-ctl-cln-bkps: switch to sys-service; pass CLI args via ExecStart; add ExecStartPre lock; set OnFailure; copy files; remove role-specific service template.

sys-ctl-cln-disc-space: switch to sys-service; enable timer; set OnFailure; provide ExecStart/ExecStartPre; copy files; remove role-specific service template.

script.sh (disc-space): non-interactive docker exec; consistent threshold message (use parameter); guard docker/pacman via command checks; robust container check; fix typo; use POSIX '='.

svc-opt-keyboard-color: minor formatting cleanup.

sys-ctl-hlth-disc-space: chain OnFailure to cleanup-disc-space service.

Context: ChatGPT conversation (Sep 10, 2025, Europe/Berlin) — https://chatgpt.com/share/68c1982e-bdc8-800f-bf13-a8b9f084f90e
2025-09-10 17:24:56 +02:00
..

Cleanup Backups Service

Description

This role automates the cleanup of old backups by executing a Python script that deletes outdated backup versions based on disk usage thresholds. It ensures that backup storage does not exceed a defined usage percentage.

Overview

Optimized for effective disk space management, this role:

  • Installs required packages (e.g. lsof and psutil) using pacman.
  • Creates a directory for storing cleanup scripts.
  • Deploys a Python script that deletes old backup directories when disk usage is too high.
  • Configures a systemd service to run the cleanup script, with notifications via sys-ctl-alm-compose.

Purpose

The primary purpose of this role is to maintain optimal backup storage by automatically removing outdated backup versions when disk usage exceeds a specified threshold.

Features

  • Automated Cleanup: Executes a Python script to delete old backups.
  • Threshold-Based Deletion: Removes backups based on disk usage percentage.
  • Systemd Integration: Configures a systemd service to run cleanup tasks.
  • Dependency Integration: Works in conjunction with related roles for comprehensive backup management.

Other Resources