From 33bbd6a1dfd425084c291302b26178ed25cb2e76 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 16 Nov 2023 17:07:28 +0100 Subject: [PATCH] Renamed to backup and cleanup roles --- README.md | 4 ++-- playbook.yml | 4 ++-- .../README.md | 2 +- .../files/backup-data-to-usb.python} | 2 +- roles/backup-data-to-usb/handlers/main.yml | 6 +++++ roles/backup-data-to-usb/meta/main.yml | 3 +++ .../tasks/main.yml | 8 +++---- .../templates/backup-data-to-usb.service.j2} | 0 .../vars/main.yml | 2 +- roles/backup-docker-cleanup/README.md | 3 --- roles/backup-docker-cleanup/handlers/main.yml | 5 ----- roles/backup-docker-cleanup/tasks/main.yml | 18 --------------- .../backup-docker-to-local/handlers/main.yml | 12 ++++++++++ .../meta/main.yml | 2 +- .../tasks/main.yml | 18 +++++++-------- .../backup-docker-to-local.service.j2} | 4 ++-- .../backup-docker-to-local.timer.j2} | 0 .../vars/main.yml | 2 +- roles/backup-docker/handlers/main.yml | 12 ---------- roles/backup-to-usb/handlers/main.yml | 6 ----- roles/backup-to-usb/meta/main.yml | 3 --- roles/backups-cleanup-timer/meta/main.yml | 2 -- roles/backups-consumer/meta/main.yml | 4 ++-- .../templates/pull-remote-backups.service.j2 | 2 +- .../files/ssh-wrapper.sh | 4 ++-- roles/backups-provider/meta/main.yml | 2 +- .../README.md | 2 +- .../files/backups-cleanup.py | 0 .../handlers/main.yml | 0 .../meta/main.yml | 0 .../tasks/main.yml | 0 .../templates/backups-cleanup.service.j2 | 0 .../vars/main.yml | 0 .../README.md | 2 +- .../handlers/main.yml | 0 roles/cleanup-backups-timer/meta/main.yml | 2 ++ .../tasks/main.yml | 0 .../templates/backups-cleanup.timer.j2 | 0 .../README.md | 2 +- roles/cleanup-disc-space/handlers/main.yml | 12 ++++++++++ .../meta/main.yml | 0 roles/cleanup-disc-space/tasks/main.yml | 22 +++++++++++++++++++ .../templates/cleanup-disc-space.service.j2} | 2 +- .../templates/cleanup-disc-space.sh.j2} | 0 .../templates/cleanup-disc-space.timer.j2} | 2 +- roles/cleanup-disc-space/vars/main.yml | 1 + roles/cleanup-failed-docker-backups/README.md | 3 +++ .../handlers/main.yml | 5 +++++ .../meta/main.yml | 0 .../tasks/main.yml | 18 +++++++++++++++ .../cleanup-failed-docker-backups.service.j2} | 0 .../vars/main.yml | 2 +- roles/docker-akaunting/README.md | 2 +- .../files/docker-compose-restart-unhealthy.py | 2 +- roles/docker-nextcloud/README.md | 4 ++-- roles/docker/meta/main.yml | 2 +- roles/free-disc-space/handlers/main.yml | 12 ---------- roles/free-disc-space/tasks/main.yml | 22 ------------------- roles/free-disc-space/vars/main.yml | 1 - 59 files changed, 125 insertions(+), 125 deletions(-) rename roles/{backup-to-usb => backup-data-to-usb}/README.md (96%) rename roles/{backup-to-usb/files/backup-to-usb.python => backup-data-to-usb/files/backup-data-to-usb.python} (98%) create mode 100644 roles/backup-data-to-usb/handlers/main.yml create mode 100644 roles/backup-data-to-usb/meta/main.yml rename roles/{backup-to-usb => backup-data-to-usb}/tasks/main.yml (60%) rename roles/{backup-to-usb/templates/backup-to-usb.service.j2 => backup-data-to-usb/templates/backup-data-to-usb.service.j2} (100%) rename roles/{backup-to-usb => backup-data-to-usb}/vars/main.yml (77%) delete mode 100644 roles/backup-docker-cleanup/README.md delete mode 100644 roles/backup-docker-cleanup/handlers/main.yml delete mode 100644 roles/backup-docker-cleanup/tasks/main.yml create mode 100644 roles/backup-docker-to-local/handlers/main.yml rename roles/{backup-docker => backup-docker-to-local}/meta/main.yml (65%) rename roles/{backup-docker => backup-docker-to-local}/tasks/main.yml (55%) rename roles/{backup-docker/templates/backup-docker.service.j2 => backup-docker-to-local/templates/backup-docker-to-local.service.j2} (57%) rename roles/{backup-docker/templates/backup-docker.timer.j2 => backup-docker-to-local/templates/backup-docker-to-local.timer.j2} (100%) rename roles/{backup-docker => backup-docker-to-local}/vars/main.yml (76%) delete mode 100644 roles/backup-docker/handlers/main.yml delete mode 100644 roles/backup-to-usb/handlers/main.yml delete mode 100644 roles/backup-to-usb/meta/main.yml delete mode 100644 roles/backups-cleanup-timer/meta/main.yml rename roles/{backups-cleanup-service => cleanup-backups-service}/README.md (89%) rename roles/{backups-cleanup-service => cleanup-backups-service}/files/backups-cleanup.py (100%) rename roles/{backups-cleanup-service => cleanup-backups-service}/handlers/main.yml (100%) rename roles/{backups-cleanup-service => cleanup-backups-service}/meta/main.yml (100%) rename roles/{backups-cleanup-service => cleanup-backups-service}/tasks/main.yml (100%) rename roles/{backups-cleanup-service => cleanup-backups-service}/templates/backups-cleanup.service.j2 (100%) rename roles/{backups-cleanup-service => cleanup-backups-service}/vars/main.yml (100%) rename roles/{backups-cleanup-timer => cleanup-backups-timer}/README.md (53%) rename roles/{backups-cleanup-timer => cleanup-backups-timer}/handlers/main.yml (100%) create mode 100644 roles/cleanup-backups-timer/meta/main.yml rename roles/{backups-cleanup-timer => cleanup-backups-timer}/tasks/main.yml (100%) rename roles/{backups-cleanup-timer => cleanup-backups-timer}/templates/backups-cleanup.timer.j2 (100%) rename roles/{free-disc-space => cleanup-disc-space}/README.md (81%) create mode 100644 roles/cleanup-disc-space/handlers/main.yml rename roles/{free-disc-space => cleanup-disc-space}/meta/main.yml (100%) create mode 100644 roles/cleanup-disc-space/tasks/main.yml rename roles/{free-disc-space/templates/free-disc-space.service.j2 => cleanup-disc-space/templates/cleanup-disc-space.service.j2} (50%) rename roles/{free-disc-space/templates/free-disc-space.sh.j2 => cleanup-disc-space/templates/cleanup-disc-space.sh.j2} (100%) rename roles/{free-disc-space/templates/free-disc-space.timer.j2 => cleanup-disc-space/templates/cleanup-disc-space.timer.j2} (76%) create mode 100644 roles/cleanup-disc-space/vars/main.yml create mode 100644 roles/cleanup-failed-docker-backups/README.md create mode 100644 roles/cleanup-failed-docker-backups/handlers/main.yml rename roles/{backup-docker-cleanup => cleanup-failed-docker-backups}/meta/main.yml (100%) create mode 100644 roles/cleanup-failed-docker-backups/tasks/main.yml rename roles/{backup-docker-cleanup/templates/backup-docker-cleanup.service.j2 => cleanup-failed-docker-backups/templates/cleanup-failed-docker-backups.service.j2} (100%) rename roles/{backup-docker-cleanup => cleanup-failed-docker-backups}/vars/main.yml (64%) delete mode 100644 roles/free-disc-space/handlers/main.yml delete mode 100644 roles/free-disc-space/tasks/main.yml delete mode 100644 roles/free-disc-space/vars/main.yml diff --git a/README.md b/README.md index 8961c45c..ade05458 100644 --- a/README.md +++ b/README.md @@ -30,11 +30,11 @@ This software allows to setup the docker following applications: #### Native Applications This software shipts the following tools which are natively setup on the server: -- [Backups Cleanup](./roles/backups-cleanup-timer/README.md) - Cleans up old backups +- [Backups Cleanup](./roles/cleanup-backups-timer/README.md) - Cleans up old backups - [Btrfs Health Check](./roles/health-btrfs/README.md) - Checks the health of Btrfs file systems - [Docker Health Check](./roles/health-docker/) - Checks the health of docker containers - [Docker Reverse Proxy](./roles/docker-reverse-proxy/README.md) - Docker Reverse Proxy Solution -- [Docker Volume Backup](./roles/backup-docker/) - Backup Solution for Docker Volumes +- [Docker Volume Backup](./roles/backup-docker-to-local/) - Backup Solution for Docker Volumes - [Pull Primary Backups](./roles/backups-consumer/README.md) - Pulls the backups from another server and stores them - [Wireguard](./roles/wireguard/README.md) - Integrates the server in an wireguard vpn diff --git a/playbook.yml b/playbook.yml index c3b77740..b8c84da5 100644 --- a/playbook.yml +++ b/playbook.yml @@ -12,7 +12,7 @@ - system-security - journalctl - health-disc-space - - free-disc-space + - cleanup-disc-space - health-btrfs # Wireguard Rollen @@ -321,4 +321,4 @@ hosts: backup_to_usb become: true roles: - - backup-to-usb \ No newline at end of file + - backup-data-to-usb \ No newline at end of file diff --git a/roles/backup-to-usb/README.md b/roles/backup-data-to-usb/README.md similarity index 96% rename from roles/backup-to-usb/README.md rename to roles/backup-data-to-usb/README.md index d3d74ead..96718aa1 100644 --- a/roles/backup-to-usb/README.md +++ b/roles/backup-data-to-usb/README.md @@ -1,4 +1,4 @@ -# backup-to-usb +# backup-data-to-usb This Ansible role automates the process of performing backups to a swappable USB device. diff --git a/roles/backup-to-usb/files/backup-to-usb.python b/roles/backup-data-to-usb/files/backup-data-to-usb.python similarity index 98% rename from roles/backup-to-usb/files/backup-to-usb.python rename to roles/backup-data-to-usb/files/backup-data-to-usb.python index 41a341d8..8f130c4e 100644 --- a/roles/backup-to-usb/files/backup-to-usb.python +++ b/roles/backup-data-to-usb/files/backup-data-to-usb.python @@ -21,7 +21,7 @@ def main(): machine_id = subprocess.run(["sha256sum", "/etc/machine-id"], capture_output=True, text=True).stdout.strip()[:64] print(f"machine id: {machine_id}") - versions_path = os.path.join(backup_to_usb_destination_path, f"{machine_id}/backup-to-usb/") + versions_path = os.path.join(backup_to_usb_destination_path, f"{machine_id}/backup-data-to-usb/") print(f"versions path: {versions_path}") if not os.path.isdir(versions_path): diff --git a/roles/backup-data-to-usb/handlers/main.yml b/roles/backup-data-to-usb/handlers/main.yml new file mode 100644 index 00000000..10f545f8 --- /dev/null +++ b/roles/backup-data-to-usb/handlers/main.yml @@ -0,0 +1,6 @@ +- name: "reload backup-data-to-usb.service" + systemd: + name: backup-data-to-usb.service + state: reloaded + enabled: yes + daemon_reload: yes diff --git a/roles/backup-data-to-usb/meta/main.yml b/roles/backup-data-to-usb/meta/main.yml new file mode 100644 index 00000000..3d2637ce --- /dev/null +++ b/roles/backup-data-to-usb/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - role: cleanup-backups-service diff --git a/roles/backup-to-usb/tasks/main.yml b/roles/backup-data-to-usb/tasks/main.yml similarity index 60% rename from roles/backup-to-usb/tasks/main.yml rename to roles/backup-data-to-usb/tasks/main.yml index 6d64d0a1..54d432ad 100644 --- a/roles/backup-to-usb/tasks/main.yml +++ b/roles/backup-data-to-usb/tasks/main.yml @@ -1,6 +1,6 @@ - name: Copy backup script to the scripts directory copy: - src: backup-to-usb.python + src: backup-data-to-usb.python dest: "{{ backup_to_usb_script_path }}" owner: root group: root @@ -8,9 +8,9 @@ - name: Copy systemd service to systemd directory template: - src: backup-to-usb.service.j2 - dest: /etc/systemd/system/backup-to-usb.service + src: backup-data-to-usb.service.j2 + dest: /etc/systemd/system/backup-data-to-usb.service owner: root group: root mode: '0644' - notify: reload backup-to-usb.service \ No newline at end of file + notify: reload backup-data-to-usb.service \ No newline at end of file diff --git a/roles/backup-to-usb/templates/backup-to-usb.service.j2 b/roles/backup-data-to-usb/templates/backup-data-to-usb.service.j2 similarity index 100% rename from roles/backup-to-usb/templates/backup-to-usb.service.j2 rename to roles/backup-data-to-usb/templates/backup-data-to-usb.service.j2 diff --git a/roles/backup-to-usb/vars/main.yml b/roles/backup-data-to-usb/vars/main.yml similarity index 77% rename from roles/backup-to-usb/vars/main.yml rename to roles/backup-data-to-usb/vars/main.yml index 4bc6427d..85c561d0 100644 --- a/roles/backup-to-usb/vars/main.yml +++ b/roles/backup-data-to-usb/vars/main.yml @@ -1,4 +1,4 @@ -backup_to_usb_script_path: "/usr/local/sbin/backup-to-usb.python" +backup_to_usb_script_path: "/usr/local/sbin/backup-data-to-usb.python" backup_to_usb_destination: "{{backup_to_usb_mount}}{{backup_to_usb_destination_subdirectory}}" backups_folder_path: "{{backup_to_usb_destination}}" systemctl_mount_service_name: "{{ backup_to_usb_mount | trim('/') | replace('/', '-') }}.mount" \ No newline at end of file diff --git a/roles/backup-docker-cleanup/README.md b/roles/backup-docker-cleanup/README.md deleted file mode 100644 index 5bea87a0..00000000 --- a/roles/backup-docker-cleanup/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Docker Volume Backup Cleanup -This script cleans up failed docker backups. -It uses https://github.com/kevinveenbirkenbach/backup-docker-cleanup as base. \ No newline at end of file diff --git a/roles/backup-docker-cleanup/handlers/main.yml b/roles/backup-docker-cleanup/handlers/main.yml deleted file mode 100644 index 5fb3172c..00000000 --- a/roles/backup-docker-cleanup/handlers/main.yml +++ /dev/null @@ -1,5 +0,0 @@ -- name: "reload backup-docker-cleanup.service daemon" - systemd: - name: backup-docker-cleanup.service - enabled: yes - daemon_reload: yes diff --git a/roles/backup-docker-cleanup/tasks/main.yml b/roles/backup-docker-cleanup/tasks/main.yml deleted file mode 100644 index 192bd0dd..00000000 --- a/roles/backup-docker-cleanup/tasks/main.yml +++ /dev/null @@ -1,18 +0,0 @@ -- name: pull backup-docker-cleanup.git - git: - repo: "https://github.com/kevinveenbirkenbach/backup-docker-cleanup.git" - dest: "{{docker_volume_backup_cleanup_folder}}" - update: yes - register: git_result - ignore_errors: true - -- name: Warn if repo is not reachable - debug: - msg: "Warning: Repository is not reachable." - when: git_result.failed - -- name: configure backup-docker-cleanup.service - template: - src: backup-docker-cleanup.service.j2 - dest: /etc/systemd/system/backup-docker-cleanup.service - notify: reload backup-docker-cleanup.service daemon \ No newline at end of file diff --git a/roles/backup-docker-to-local/handlers/main.yml b/roles/backup-docker-to-local/handlers/main.yml new file mode 100644 index 00000000..b88d910d --- /dev/null +++ b/roles/backup-docker-to-local/handlers/main.yml @@ -0,0 +1,12 @@ +- name: "reload backup-docker-to-local.service" + systemd: + name: backup-docker-to-local.service + enabled: yes + daemon_reload: yes + +- name: "restart backup-docker-to-local.timer" + systemd: + name: backup-docker-to-local.timer + state: started + enabled: yes + daemon_reload: yes diff --git a/roles/backup-docker/meta/main.yml b/roles/backup-docker-to-local/meta/main.yml similarity index 65% rename from roles/backup-docker/meta/main.yml rename to roles/backup-docker-to-local/meta/main.yml index 11e4c704..8d6565bd 100644 --- a/roles/backup-docker/meta/main.yml +++ b/roles/backup-docker-to-local/meta/main.yml @@ -2,4 +2,4 @@ dependencies: - git - backups-provider - systemd_notifier - - backup-docker-cleanup \ No newline at end of file + - cleanup-failed-docker-backups \ No newline at end of file diff --git a/roles/backup-docker/tasks/main.yml b/roles/backup-docker-to-local/tasks/main.yml similarity index 55% rename from roles/backup-docker/tasks/main.yml rename to roles/backup-docker-to-local/tasks/main.yml index 6fcbc0b0..255cb876 100644 --- a/roles/backup-docker/tasks/main.yml +++ b/roles/backup-docker-to-local/tasks/main.yml @@ -5,9 +5,9 @@ - python-pandas state: present -- name: pull backup-docker.git +- name: pull backup-docker-to-local.git git: - repo: "https://github.com/kevinveenbirkenbach/backup-docker.git" + repo: "https://github.com/kevinveenbirkenbach/backup-docker-to-local.git" dest: "{{docker_volume_backup_folder}}" update: yes register: git_result @@ -18,15 +18,15 @@ msg: "Warning: Repository is not reachable." when: git_result.failed -- name: configure backup-docker.service +- name: configure backup-docker-to-local.service template: - src: backup-docker.service.j2 - dest: /etc/systemd/system/backup-docker.service - notify: reload backup-docker.service + src: backup-docker-to-local.service.j2 + dest: /etc/systemd/system/backup-docker-to-local.service + notify: reload backup-docker-to-local.service -- name: configure backup-docker.timer.tpl - template: src=backup-docker.timer.j2 dest=/etc/systemd/system/backup-docker.timer - notify: restart backup-docker.timer +- name: configure backup-docker-to-local.timer.tpl + template: src=backup-docker-to-local.timer.j2 dest=/etc/systemd/system/backup-docker-to-local.timer + notify: restart backup-docker-to-local.timer - name: create {{docker_volume_backup_folder}}databases.csv copy: diff --git a/roles/backup-docker/templates/backup-docker.service.j2 b/roles/backup-docker-to-local/templates/backup-docker-to-local.service.j2 similarity index 57% rename from roles/backup-docker/templates/backup-docker.service.j2 rename to roles/backup-docker-to-local/templates/backup-docker-to-local.service.j2 index ade41073..1a7fe128 100644 --- a/roles/backup-docker/templates/backup-docker.service.j2 +++ b/roles/backup-docker-to-local/templates/backup-docker-to-local.service.j2 @@ -1,7 +1,7 @@ [Unit] Description=docker volume backup -OnFailure=systemd-notifier@%n.service backup-docker-cleanup.service +OnFailure=systemd-notifier@%n.service cleanup-failed-docker-backups.service [Service] Type=oneshot -ExecStart=/usr/bin/python {{docker_volume_backup_folder}}backup-docker.py \ No newline at end of file +ExecStart=/usr/bin/python {{docker_volume_backup_folder}}backup-docker-to-local.py \ No newline at end of file diff --git a/roles/backup-docker/templates/backup-docker.timer.j2 b/roles/backup-docker-to-local/templates/backup-docker-to-local.timer.j2 similarity index 100% rename from roles/backup-docker/templates/backup-docker.timer.j2 rename to roles/backup-docker-to-local/templates/backup-docker-to-local.timer.j2 diff --git a/roles/backup-docker/vars/main.yml b/roles/backup-docker-to-local/vars/main.yml similarity index 76% rename from roles/backup-docker/vars/main.yml rename to roles/backup-docker-to-local/vars/main.yml index 28847cf0..9bedb65e 100644 --- a/roles/backup-docker/vars/main.yml +++ b/roles/backup-docker-to-local/vars/main.yml @@ -1 +1 @@ -docker_volume_backup_folder: "{{path_administrator_scripts}}backup-docker/" \ No newline at end of file +docker_volume_backup_folder: "{{path_administrator_scripts}}backup-docker-to-local/" \ No newline at end of file diff --git a/roles/backup-docker/handlers/main.yml b/roles/backup-docker/handlers/main.yml deleted file mode 100644 index 7fbc05b0..00000000 --- a/roles/backup-docker/handlers/main.yml +++ /dev/null @@ -1,12 +0,0 @@ -- name: "reload backup-docker.service" - systemd: - name: backup-docker.service - enabled: yes - daemon_reload: yes - -- name: "restart backup-docker.timer" - systemd: - name: backup-docker.timer - state: started - enabled: yes - daemon_reload: yes diff --git a/roles/backup-to-usb/handlers/main.yml b/roles/backup-to-usb/handlers/main.yml deleted file mode 100644 index 7f986191..00000000 --- a/roles/backup-to-usb/handlers/main.yml +++ /dev/null @@ -1,6 +0,0 @@ -- name: "reload backup-to-usb.service" - systemd: - name: backup-to-usb.service - state: reloaded - enabled: yes - daemon_reload: yes diff --git a/roles/backup-to-usb/meta/main.yml b/roles/backup-to-usb/meta/main.yml deleted file mode 100644 index ad475a48..00000000 --- a/roles/backup-to-usb/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - role: backups-cleanup-service diff --git a/roles/backups-cleanup-timer/meta/main.yml b/roles/backups-cleanup-timer/meta/main.yml deleted file mode 100644 index 1fde040a..00000000 --- a/roles/backups-cleanup-timer/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: - - backups-cleanup-service diff --git a/roles/backups-consumer/meta/main.yml b/roles/backups-consumer/meta/main.yml index 7508b80b..4737a901 100644 --- a/roles/backups-consumer/meta/main.yml +++ b/roles/backups-consumer/meta/main.yml @@ -1,5 +1,5 @@ dependencies: - git - systemd_notifier - - backups-cleanup-timer - - backup-docker-cleanup + - cleanup-backups-timer + - cleanup-failed-docker-backups diff --git a/roles/backups-consumer/templates/pull-remote-backups.service.j2 b/roles/backups-consumer/templates/pull-remote-backups.service.j2 index 396f081d..f05845b6 100644 --- a/roles/backups-consumer/templates/pull-remote-backups.service.j2 +++ b/roles/backups-consumer/templates/pull-remote-backups.service.j2 @@ -1,6 +1,6 @@ [Unit] Description=pull remote backups -OnFailure=systemd-notifier@%n.service backup-docker-cleanup.service +OnFailure=systemd-notifier@%n.service cleanup-failed-docker-backups.service [Service] Type=oneshot diff --git a/roles/backups-provider-user/files/ssh-wrapper.sh b/roles/backups-provider-user/files/ssh-wrapper.sh index 595af46e..a2733334 100644 --- a/roles/backups-provider-user/files/ssh-wrapper.sh +++ b/roles/backups-provider-user/files/ssh-wrapper.sh @@ -12,8 +12,8 @@ hashed_machine_id="$($get_hashed_machine_id | head -c 64)" get_backup_types="find /Backups/$hashed_machine_id/ -maxdepth 1 -type d -execdir basename {} ;"; -# @todo This configuration is not scalable yet. If other backup services then backup-docker are integrated, this logic needs to be optimized -get_version_directories="ls -d /Backups/$hashed_machine_id/backup-docker/*" +# @todo This configuration is not scalable yet. If other backup services then backup-docker-to-local are integrated, this logic needs to be optimized +get_version_directories="ls -d /Backups/$hashed_machine_id/backup-docker-to-local/*" last_version_directory="$($get_version_directories | tail -1)" rsync_command="sudo rsync --server --sender -blogDtpre.iLsfxCIvu . $last_version_directory/" diff --git a/roles/backups-provider/meta/main.yml b/roles/backups-provider/meta/main.yml index 42922c94..ef0085c3 100644 --- a/roles/backups-provider/meta/main.yml +++ b/roles/backups-provider/meta/main.yml @@ -1,3 +1,3 @@ dependencies: - backups-provider-user -- backups-cleanup-timer +- cleanup-backups-timer diff --git a/roles/backups-cleanup-service/README.md b/roles/cleanup-backups-service/README.md similarity index 89% rename from roles/backups-cleanup-service/README.md rename to roles/cleanup-backups-service/README.md index 73dafa9b..659799d0 100644 --- a/roles/backups-cleanup-service/README.md +++ b/roles/cleanup-backups-service/README.md @@ -1,4 +1,4 @@ -# role backups-cleanup-timer +# role cleanup-backups-timer Cleans up old backups diff --git a/roles/backups-cleanup-service/files/backups-cleanup.py b/roles/cleanup-backups-service/files/backups-cleanup.py similarity index 100% rename from roles/backups-cleanup-service/files/backups-cleanup.py rename to roles/cleanup-backups-service/files/backups-cleanup.py diff --git a/roles/backups-cleanup-service/handlers/main.yml b/roles/cleanup-backups-service/handlers/main.yml similarity index 100% rename from roles/backups-cleanup-service/handlers/main.yml rename to roles/cleanup-backups-service/handlers/main.yml diff --git a/roles/backups-cleanup-service/meta/main.yml b/roles/cleanup-backups-service/meta/main.yml similarity index 100% rename from roles/backups-cleanup-service/meta/main.yml rename to roles/cleanup-backups-service/meta/main.yml diff --git a/roles/backups-cleanup-service/tasks/main.yml b/roles/cleanup-backups-service/tasks/main.yml similarity index 100% rename from roles/backups-cleanup-service/tasks/main.yml rename to roles/cleanup-backups-service/tasks/main.yml diff --git a/roles/backups-cleanup-service/templates/backups-cleanup.service.j2 b/roles/cleanup-backups-service/templates/backups-cleanup.service.j2 similarity index 100% rename from roles/backups-cleanup-service/templates/backups-cleanup.service.j2 rename to roles/cleanup-backups-service/templates/backups-cleanup.service.j2 diff --git a/roles/backups-cleanup-service/vars/main.yml b/roles/cleanup-backups-service/vars/main.yml similarity index 100% rename from roles/backups-cleanup-service/vars/main.yml rename to roles/cleanup-backups-service/vars/main.yml diff --git a/roles/backups-cleanup-timer/README.md b/roles/cleanup-backups-timer/README.md similarity index 53% rename from roles/backups-cleanup-timer/README.md rename to roles/cleanup-backups-timer/README.md index 1c616c4f..b619ba81 100644 --- a/roles/backups-cleanup-timer/README.md +++ b/roles/cleanup-backups-timer/README.md @@ -1,3 +1,3 @@ -# role backups-cleanup-timer +# role cleanup-backups-timer Timer for cleaning up old backups \ No newline at end of file diff --git a/roles/backups-cleanup-timer/handlers/main.yml b/roles/cleanup-backups-timer/handlers/main.yml similarity index 100% rename from roles/backups-cleanup-timer/handlers/main.yml rename to roles/cleanup-backups-timer/handlers/main.yml diff --git a/roles/cleanup-backups-timer/meta/main.yml b/roles/cleanup-backups-timer/meta/main.yml new file mode 100644 index 00000000..d17982fb --- /dev/null +++ b/roles/cleanup-backups-timer/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - cleanup-backups-service diff --git a/roles/backups-cleanup-timer/tasks/main.yml b/roles/cleanup-backups-timer/tasks/main.yml similarity index 100% rename from roles/backups-cleanup-timer/tasks/main.yml rename to roles/cleanup-backups-timer/tasks/main.yml diff --git a/roles/backups-cleanup-timer/templates/backups-cleanup.timer.j2 b/roles/cleanup-backups-timer/templates/backups-cleanup.timer.j2 similarity index 100% rename from roles/backups-cleanup-timer/templates/backups-cleanup.timer.j2 rename to roles/cleanup-backups-timer/templates/backups-cleanup.timer.j2 diff --git a/roles/free-disc-space/README.md b/roles/cleanup-disc-space/README.md similarity index 81% rename from roles/free-disc-space/README.md rename to roles/cleanup-disc-space/README.md index 16328dae..8fdb66ea 100644 --- a/roles/free-disc-space/README.md +++ b/roles/cleanup-disc-space/README.md @@ -1,4 +1,4 @@ -# free-disc-space +# cleanup-disc-space Frees disc space ## More information - https://askubuntu.com/questions/380238/how-to-clean-tmp \ No newline at end of file diff --git a/roles/cleanup-disc-space/handlers/main.yml b/roles/cleanup-disc-space/handlers/main.yml new file mode 100644 index 00000000..670657b3 --- /dev/null +++ b/roles/cleanup-disc-space/handlers/main.yml @@ -0,0 +1,12 @@ +- name: "reload cleanup-disc-space.service" + systemd: + name: cleanup-disc-space.service + state: reloaded + enabled: yes + daemon_reload: yes +- name: "restart cleanup-disc-space.timer" + systemd: + name: cleanup-disc-space.timer + state: restarted + enabled: yes + daemon_reload: yes diff --git a/roles/free-disc-space/meta/main.yml b/roles/cleanup-disc-space/meta/main.yml similarity index 100% rename from roles/free-disc-space/meta/main.yml rename to roles/cleanup-disc-space/meta/main.yml diff --git a/roles/cleanup-disc-space/tasks/main.yml b/roles/cleanup-disc-space/tasks/main.yml new file mode 100644 index 00000000..1b0e198d --- /dev/null +++ b/roles/cleanup-disc-space/tasks/main.yml @@ -0,0 +1,22 @@ +- name: "create {{free_disc_space_folder}}" + file: + path: "{{free_disc_space_folder}}" + state: directory + mode: 0755 + +- name: create cleanup-disc-space.sh + template: + src: cleanup-disc-space.sh.j2 + dest: "{{free_disc_space_folder}}cleanup-disc-space.sh" + +- name: create cleanup-disc-space.service + template: + src: cleanup-disc-space.service.j2 + dest: /etc/systemd/system/cleanup-disc-space.service + notify: reload cleanup-disc-space.service + +- name: create cleanup-disc-space.timer + template: + src: cleanup-disc-space.timer.j2 + dest: /etc/systemd/system/cleanup-disc-space.timer + notify: restart cleanup-disc-space.timer \ No newline at end of file diff --git a/roles/free-disc-space/templates/free-disc-space.service.j2 b/roles/cleanup-disc-space/templates/cleanup-disc-space.service.j2 similarity index 50% rename from roles/free-disc-space/templates/free-disc-space.service.j2 rename to roles/cleanup-disc-space/templates/cleanup-disc-space.service.j2 index 62c17e59..47e4c0a4 100644 --- a/roles/free-disc-space/templates/free-disc-space.service.j2 +++ b/roles/cleanup-disc-space/templates/cleanup-disc-space.service.j2 @@ -4,4 +4,4 @@ OnFailure=systemd-notifier@%n.service [Service] Type=oneshot -ExecStart=/bin/bash {{free_disc_space_folder}}free-disc-space.sh {{size_percent_free_disc_space}} \ No newline at end of file +ExecStart=/bin/bash {{free_disc_space_folder}}cleanup-disc-space.sh {{size_percent_free_disc_space}} \ No newline at end of file diff --git a/roles/free-disc-space/templates/free-disc-space.sh.j2 b/roles/cleanup-disc-space/templates/cleanup-disc-space.sh.j2 similarity index 100% rename from roles/free-disc-space/templates/free-disc-space.sh.j2 rename to roles/cleanup-disc-space/templates/cleanup-disc-space.sh.j2 diff --git a/roles/free-disc-space/templates/free-disc-space.timer.j2 b/roles/cleanup-disc-space/templates/cleanup-disc-space.timer.j2 similarity index 76% rename from roles/free-disc-space/templates/free-disc-space.timer.j2 rename to roles/cleanup-disc-space/templates/cleanup-disc-space.timer.j2 index be316e78..9295d05f 100644 --- a/roles/free-disc-space/templates/free-disc-space.timer.j2 +++ b/roles/cleanup-disc-space/templates/cleanup-disc-space.timer.j2 @@ -1,5 +1,5 @@ [Unit] -Description=starts free-disc-space.service +Description=starts cleanup-disc-space.service [Timer] OnCalendar={{on_calendar_free_disc_space}} diff --git a/roles/cleanup-disc-space/vars/main.yml b/roles/cleanup-disc-space/vars/main.yml new file mode 100644 index 00000000..020d45f5 --- /dev/null +++ b/roles/cleanup-disc-space/vars/main.yml @@ -0,0 +1 @@ +free_disc_space_folder: "{{path_administrator_scripts}}cleanup-disc-space/" \ No newline at end of file diff --git a/roles/cleanup-failed-docker-backups/README.md b/roles/cleanup-failed-docker-backups/README.md new file mode 100644 index 00000000..3873e687 --- /dev/null +++ b/roles/cleanup-failed-docker-backups/README.md @@ -0,0 +1,3 @@ +# Docker Volume Backup Cleanup +This script cleans up failed docker backups. +It uses https://github.com/kevinveenbirkenbach/cleanup-failed-docker-backups as base. \ No newline at end of file diff --git a/roles/cleanup-failed-docker-backups/handlers/main.yml b/roles/cleanup-failed-docker-backups/handlers/main.yml new file mode 100644 index 00000000..e22f29e5 --- /dev/null +++ b/roles/cleanup-failed-docker-backups/handlers/main.yml @@ -0,0 +1,5 @@ +- name: "reload cleanup-failed-docker-backups.service daemon" + systemd: + name: cleanup-failed-docker-backups.service + enabled: yes + daemon_reload: yes diff --git a/roles/backup-docker-cleanup/meta/main.yml b/roles/cleanup-failed-docker-backups/meta/main.yml similarity index 100% rename from roles/backup-docker-cleanup/meta/main.yml rename to roles/cleanup-failed-docker-backups/meta/main.yml diff --git a/roles/cleanup-failed-docker-backups/tasks/main.yml b/roles/cleanup-failed-docker-backups/tasks/main.yml new file mode 100644 index 00000000..46292718 --- /dev/null +++ b/roles/cleanup-failed-docker-backups/tasks/main.yml @@ -0,0 +1,18 @@ +- name: pull cleanup-failed-docker-backups.git + git: + repo: "https://github.com/kevinveenbirkenbach/cleanup-failed-docker-backups.git" + dest: "{{docker_volume_backup_cleanup_folder}}" + update: yes + register: git_result + ignore_errors: true + +- name: Warn if repo is not reachable + debug: + msg: "Warning: Repository is not reachable." + when: git_result.failed + +- name: configure cleanup-failed-docker-backups.service + template: + src: cleanup-failed-docker-backups.service.j2 + dest: /etc/systemd/system/cleanup-failed-docker-backups.service + notify: reload cleanup-failed-docker-backups.service daemon \ No newline at end of file diff --git a/roles/backup-docker-cleanup/templates/backup-docker-cleanup.service.j2 b/roles/cleanup-failed-docker-backups/templates/cleanup-failed-docker-backups.service.j2 similarity index 100% rename from roles/backup-docker-cleanup/templates/backup-docker-cleanup.service.j2 rename to roles/cleanup-failed-docker-backups/templates/cleanup-failed-docker-backups.service.j2 diff --git a/roles/backup-docker-cleanup/vars/main.yml b/roles/cleanup-failed-docker-backups/vars/main.yml similarity index 64% rename from roles/backup-docker-cleanup/vars/main.yml rename to roles/cleanup-failed-docker-backups/vars/main.yml index 1114eb23..233cb0bc 100644 --- a/roles/backup-docker-cleanup/vars/main.yml +++ b/roles/cleanup-failed-docker-backups/vars/main.yml @@ -1 +1 @@ -docker_volume_backup_cleanup_folder: "{{path_administrator_scripts}}backup-docker-cleanup/" \ No newline at end of file +docker_volume_backup_cleanup_folder: "{{path_administrator_scripts}}cleanup-failed-docker-backups/" \ No newline at end of file diff --git a/roles/docker-akaunting/README.md b/roles/docker-akaunting/README.md index 504d984e..ee1640b0 100644 --- a/roles/docker-akaunting/README.md +++ b/roles/docker-akaunting/README.md @@ -81,7 +81,7 @@ docker-compose build && docker-compose -p akaunting up -d --force-recreate # recover all volumes -cd {{path_administrator_scripts}}backup-docker && +cd {{path_administrator_scripts}}backup-docker-to-local && bash docker-volume-recover.sh akaunting_akaunting-modules ${machine_id:0:64} "$backup_version" && bash docker-volume-recover.sh akaunting_akaunting-data ${machine_id:0:64} "$backup_version" && bash docker-volume-recover.sh akaunting_akaunting-db ${machine_id:0:64} "$backup_version" akaunting-db "$akaunting_db_password" akaunting diff --git a/roles/docker-compose-restart-unhealthy/files/docker-compose-restart-unhealthy.py b/roles/docker-compose-restart-unhealthy/files/docker-compose-restart-unhealthy.py index 37ecc3e3..85508817 100644 --- a/roles/docker-compose-restart-unhealthy/files/docker-compose-restart-unhealthy.py +++ b/roles/docker-compose-restart-unhealthy/files/docker-compose-restart-unhealthy.py @@ -30,7 +30,7 @@ waiting_time=600 blocker_running=True while blocker_running: try: - bash("systemctl is-active --quiet backup-docker.service") + bash("systemctl is-active --quiet backup-docker-to-local.service") bash("systemctl is-active --quiet update-docker.service") print("backup is running.") print("trying again in " + str(waiting_time) + " seconds.") diff --git a/roles/docker-nextcloud/README.md b/roles/docker-nextcloud/README.md index 12b76091..79f30c1f 100644 --- a/roles/docker-nextcloud/README.md +++ b/roles/docker-nextcloud/README.md @@ -59,8 +59,8 @@ and disable the not functioning apps. ```bash cd {{path_docker_compose_files}}nextcloud && docker-compose down && -docker-compose exec -i database mysql -u nextcloud -pPASSWORT nextcloud < "/Backups/$(sha256sum /etc/machine-id | head -c 64)/backup-docker/latest/nextcloud_database/sql/backup.sql" && -cd {{path_administrator_scripts}}backup-docker && +docker-compose exec -i database mysql -u nextcloud -pPASSWORT nextcloud < "/Backups/$(sha256sum /etc/machine-id | head -c 64)/backup-docker-to-local/latest/nextcloud_database/sql/backup.sql" && +cd {{path_administrator_scripts}}backup-docker-to-local && bash ./docker-volume-recover.sh "nextcloud_data" "$(sha256sum /etc/machine-id | head -c 64)" ``` diff --git a/roles/docker/meta/main.yml b/roles/docker/meta/main.yml index 31acbadc..43ae45d0 100644 --- a/roles/docker/meta/main.yml +++ b/roles/docker/meta/main.yml @@ -1,5 +1,5 @@ dependencies: - - backup-docker + - backup-docker-to-local - user-administrator - health-docker - docker-compose-restart-unhealthy diff --git a/roles/free-disc-space/handlers/main.yml b/roles/free-disc-space/handlers/main.yml deleted file mode 100644 index 51f329b5..00000000 --- a/roles/free-disc-space/handlers/main.yml +++ /dev/null @@ -1,12 +0,0 @@ -- name: "reload free-disc-space.service" - systemd: - name: free-disc-space.service - state: reloaded - enabled: yes - daemon_reload: yes -- name: "restart free-disc-space.timer" - systemd: - name: free-disc-space.timer - state: restarted - enabled: yes - daemon_reload: yes diff --git a/roles/free-disc-space/tasks/main.yml b/roles/free-disc-space/tasks/main.yml deleted file mode 100644 index a9a5c17a..00000000 --- a/roles/free-disc-space/tasks/main.yml +++ /dev/null @@ -1,22 +0,0 @@ -- name: "create {{free_disc_space_folder}}" - file: - path: "{{free_disc_space_folder}}" - state: directory - mode: 0755 - -- name: create free-disc-space.sh - template: - src: free-disc-space.sh.j2 - dest: "{{free_disc_space_folder}}free-disc-space.sh" - -- name: create free-disc-space.service - template: - src: free-disc-space.service.j2 - dest: /etc/systemd/system/free-disc-space.service - notify: reload free-disc-space.service - -- name: create free-disc-space.timer - template: - src: free-disc-space.timer.j2 - dest: /etc/systemd/system/free-disc-space.timer - notify: restart free-disc-space.timer \ No newline at end of file diff --git a/roles/free-disc-space/vars/main.yml b/roles/free-disc-space/vars/main.yml deleted file mode 100644 index edebb2ba..00000000 --- a/roles/free-disc-space/vars/main.yml +++ /dev/null @@ -1 +0,0 @@ -free_disc_space_folder: "{{path_administrator_scripts}}free-disc-space/" \ No newline at end of file