Another big round of refactoring and cleaning...

This commit is contained in:
2025-07-11 17:55:26 +02:00
parent aa61bf2a44
commit 168c5c0da6
323 changed files with 761 additions and 811 deletions

View File

@@ -0,0 +1,24 @@
# Docker Volume Backup Cleanup Role
## Description
This role cleans up failed Docker backups by pulling a [Git repository](https://github.com/kevinveenbirkenbach/sys-cln-faild-bkps) that contains cleanup scripts and configuring a systemd service to execute them. It ensures that failed or incomplete backups are removed to free up disk space and maintain a healthy backup environment.
## Overview
Optimized for backup maintenance, this role:
- Clones the sys-cln-faild-bkps repository.
- Configures a systemd service to run the cleanup script.
- Integrates with the [sys-timer](../sys-timer/README.md) role to schedule periodic cleanup.
- Works in conjunction with the sys-bkp-directory-validator role for additional verification.
## Purpose
The primary purpose of this role is to remove failed Docker backups automatically, thereby freeing disk space and preventing backup storage from becoming cluttered with incomplete data.
## Features
- **Repository Cloning:** Retrieves the latest cleanup scripts from a Git repository.
- **Service Configuration:** Sets up a systemd service to run the cleanup tasks.
- **Timer Integration:** Schedules periodic cleanup through a systemd timer.
- **Dependency Integration:** Works with sys-bkp-directory-validator to enhance backup integrity.

View File

@@ -0,0 +1,5 @@
- name: "Reload sys-cln-faild-bkps.cymais.service"
systemd:
name: sys-cln-faild-bkps.cymais.service
enabled: yes
daemon_reload: yes

View File

@@ -0,0 +1,28 @@
---
galaxy_info:
author: "Kevin Veen-Birkenbach"
description: "Cleans up failed Docker backups by configuring a systemd service and timer to execute the cleanup operations periodically."
license: "CyMaIS NonCommercial License (CNCL)"
license_url: "https://s.veen.world/cncl"
company: |
Kevin Veen-Birkenbach
Consulting & Coaching Solutions
https://www.veen.world
min_ansible_version: "2.9"
platforms:
- name: Linux
versions:
- all
galaxy_tags:
- docker
- backup
- cleanup
- automation
repository: "https://s.veen.world/cymais"
issue_tracker_url: "https://s.veen.world/cymaisissues"
documentation: "https://s.veen.world/cymais"
dependencies:
- sys-alm-compose
- sys-lock
- sys-bkp-directory-validator
- sys-rst-daemon

View File

@@ -0,0 +1,42 @@
- name: "pkgmgr install"
include_role:
name: pkgmgr-install
vars:
package_name: "{{ cln_failed_docker_backups_pkg }}"
when: run_once_cln_failed_docker_backups is not defined
- name: "Retrieve {{ cln_failed_docker_backups_pkg }} path from pkgmgr"
command: "pkgmgr path {{ cln_failed_docker_backups_pkg }}"
register: pkgmgr_output
changed_when: false
when: run_once_cln_failed_docker_backups is not defined
- name: Set fact for backup_docker_to_local_cleanup_script
set_fact:
backup_docker_to_local_cleanup_script: "{{ pkgmgr_output.stdout.rstrip('/') ~ '/sys-cln-all.sh' }}"
changed_when: false
when: run_once_cln_failed_docker_backups is not defined
- name: configure sys-cln-faild-bkps.cymais.service
template:
src: sys-cln-faild-bkps.service.j2
dest: /etc/systemd/system/sys-cln-faild-bkps.cymais.service
notify: Reload sys-cln-faild-bkps.cymais.service
when: run_once_cln_failed_docker_backups is not defined
- name: "set 'service_name' to '{{ role_name }}'"
set_fact:
service_name: "{{ role_name }}"
when: run_once_cln_failed_docker_backups is not defined
- name: "include role for sys-timer for {{service_name}}"
include_role:
name: sys-timer
vars:
on_calendar: "{{on_calendar_cleanup_failed_docker}}"
when: run_once_cln_failed_docker_backups is not defined
- name: run the cleanup_failed_docker_backups tasks once
set_fact:
run_once_cln_failed_docker_backups: true
when: run_once_cln_failed_docker_backups is not defined

View File

@@ -0,0 +1,8 @@
[Unit]
Description=Cleaning up failed docker volume backups
OnFailure=sys-alm-compose.cymais@%n.service
[Service]
Type=oneshot
ExecStartPre=/bin/sh -c '/usr/bin/python {{ path_system_lock_script }} {{ system_maintenance_services | join(' ') }} --ignore {{system_maintenance_cleanup_services| join(' ') }} --timeout "{{system_maintenance_lock_timeout_backup_services}}"'
ExecStart=/bin/sh -c '/usr/bin/yes | /usr/bin/bash {{backup_docker_to_local_cleanup_script}}'

View File

@@ -0,0 +1,2 @@
cln_failed_docker_backups_pkg: cleanup-failed-docker-backups