From 1bcf06934df62837caaa23478a017d1651cd0208 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sat, 16 Dec 2023 12:22:31 +0100 Subject: [PATCH] Changed backup logic --- roles/system-maintenance-service-freezer/README.md | 6 ++++++ roles/update-docker/tasks/main.yml | 6 ++++++ roles/update-docker/templates/update-docker.service.j2 | 1 - 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/roles/system-maintenance-service-freezer/README.md b/roles/system-maintenance-service-freezer/README.md index 02ca67df..d497fbb0 100644 --- a/roles/system-maintenance-service-freezer/README.md +++ b/roles/system-maintenance-service-freezer/README.md @@ -3,6 +3,12 @@ ## Overview This Ansible role is designed to manage system services through freezing (disabling) and defrosting (enabling) actions. It automates the process of managing crucial system services, especially useful for maintenance tasks like backups, cleanups, and updates. +## Monitoring +To monitor the sucess of the script and the status of systemctl timers execute: + +```bash +watch -n 2 systemctl list-timers +``` ## Role Variables - `system_maintenance_services`: List of services to be managed by this role. diff --git a/roles/update-docker/tasks/main.yml b/roles/update-docker/tasks/main.yml index d57ae178..1c346513 100644 --- a/roles/update-docker/tasks/main.yml +++ b/roles/update-docker/tasks/main.yml @@ -1,3 +1,9 @@ +- name: "start backup-docker-to-local.service" + systemd: + name: backup-docker-to-local.service + state: started + when: force_backup_before_update | bool + - name: create {{update_docker_script}} copy: src: update-docker.py diff --git a/roles/update-docker/templates/update-docker.service.j2 b/roles/update-docker/templates/update-docker.service.j2 index a6d89d1d..2c1d2eaa 100644 --- a/roles/update-docker/templates/update-docker.service.j2 +++ b/roles/update-docker/templates/update-docker.service.j2 @@ -4,6 +4,5 @@ OnFailure=systemd-notifier@%n.service [Service] Type=oneshot -{% if force_backup_before_update | bool %}ExecStartPre=/bin/sh -c 'systemctl start backup-docker-to-local.service'{% endif %} ExecStartPre=/bin/sh -c '/usr/bin/python {{ path_system_maintenance_service_freezer_script }} freeze {{ system_maintenance_services | join(' ') }} --ignore {{system_maintenance_cleanup_services | join(' ') }} update-docker --timeout "{{system_maintenance_timeout_heal_docker}}"' ExecStart=/bin/sh -c '/usr/bin/python {{update_docker_script}} {{path_docker_compose_instances}} && systemctl start system-maintenance-service-defrost.service' \ No newline at end of file