From 0d4eb75afe2087dd3331ab6c3791a989d0c22447 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 16 Nov 2023 16:55:16 +0100 Subject: [PATCH] Renamed to backup-docker --- README.md | 2 +- roles/backup-docker-cleanup/README.md | 3 +++ roles/backup-docker-cleanup/handlers/main.yml | 5 +++++ .../meta/main.yml | 0 roles/backup-docker-cleanup/tasks/main.yml | 18 ++++++++++++++++++ .../backup-docker-cleanup.service.j2} | 0 .../vars/main.yml | 2 +- roles/backup-docker/handlers/main.yml | 12 ++++++++++++ .../meta/main.yml | 2 +- .../tasks/main.yml | 18 +++++++++--------- .../templates/backup-docker.service.j2 | 7 +++++++ .../templates/backup-docker.timer.j2} | 0 roles/backup-docker/vars/main.yml | 1 + roles/backups-consumer/meta/main.yml | 2 +- .../templates/pull-remote-backups.service.j2 | 2 +- .../backups-provider-user/files/ssh-wrapper.sh | 4 ++-- roles/docker-akaunting/README.md | 2 +- .../files/docker-compose-restart-unhealthy.py | 2 +- roles/docker-nextcloud/README.md | 4 ++-- roles/docker-volume-backup-cleanup/README.md | 3 --- .../handlers/main.yml | 5 ----- .../tasks/main.yml | 18 ------------------ roles/docker-volume-backup/handlers/main.yml | 12 ------------ .../templates/docker-volume-backup.service.j2 | 7 ------- roles/docker-volume-backup/vars/main.yml | 1 - roles/docker/meta/main.yml | 2 +- 26 files changed, 67 insertions(+), 67 deletions(-) create mode 100644 roles/backup-docker-cleanup/README.md create mode 100644 roles/backup-docker-cleanup/handlers/main.yml rename roles/{docker-volume-backup-cleanup => backup-docker-cleanup}/meta/main.yml (100%) create mode 100644 roles/backup-docker-cleanup/tasks/main.yml rename roles/{docker-volume-backup-cleanup/templates/docker-volume-backup-cleanup.service.j2 => backup-docker-cleanup/templates/backup-docker-cleanup.service.j2} (100%) rename roles/{docker-volume-backup-cleanup => backup-docker-cleanup}/vars/main.yml (65%) create mode 100644 roles/backup-docker/handlers/main.yml rename roles/{docker-volume-backup => backup-docker}/meta/main.yml (66%) rename roles/{docker-volume-backup => backup-docker}/tasks/main.yml (56%) create mode 100644 roles/backup-docker/templates/backup-docker.service.j2 rename roles/{docker-volume-backup/templates/docker-volume-backup.timer.j2 => backup-docker/templates/backup-docker.timer.j2} (100%) create mode 100644 roles/backup-docker/vars/main.yml delete mode 100644 roles/docker-volume-backup-cleanup/README.md delete mode 100644 roles/docker-volume-backup-cleanup/handlers/main.yml delete mode 100644 roles/docker-volume-backup-cleanup/tasks/main.yml delete mode 100644 roles/docker-volume-backup/handlers/main.yml delete mode 100644 roles/docker-volume-backup/templates/docker-volume-backup.service.j2 delete mode 100644 roles/docker-volume-backup/vars/main.yml diff --git a/README.md b/README.md index e57ad888..8961c45c 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ This software shipts the following tools which are natively setup on the server: - [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/docker-volume-backup/) - Backup Solution for Docker Volumes +- [Docker Volume Backup](./roles/backup-docker/) - 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/roles/backup-docker-cleanup/README.md b/roles/backup-docker-cleanup/README.md new file mode 100644 index 00000000..5bea87a0 --- /dev/null +++ b/roles/backup-docker-cleanup/README.md @@ -0,0 +1,3 @@ +# 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 new file mode 100644 index 00000000..5fb3172c --- /dev/null +++ b/roles/backup-docker-cleanup/handlers/main.yml @@ -0,0 +1,5 @@ +- name: "reload backup-docker-cleanup.service daemon" + systemd: + name: backup-docker-cleanup.service + enabled: yes + daemon_reload: yes diff --git a/roles/docker-volume-backup-cleanup/meta/main.yml b/roles/backup-docker-cleanup/meta/main.yml similarity index 100% rename from roles/docker-volume-backup-cleanup/meta/main.yml rename to roles/backup-docker-cleanup/meta/main.yml diff --git a/roles/backup-docker-cleanup/tasks/main.yml b/roles/backup-docker-cleanup/tasks/main.yml new file mode 100644 index 00000000..192bd0dd --- /dev/null +++ b/roles/backup-docker-cleanup/tasks/main.yml @@ -0,0 +1,18 @@ +- 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/docker-volume-backup-cleanup/templates/docker-volume-backup-cleanup.service.j2 b/roles/backup-docker-cleanup/templates/backup-docker-cleanup.service.j2 similarity index 100% rename from roles/docker-volume-backup-cleanup/templates/docker-volume-backup-cleanup.service.j2 rename to roles/backup-docker-cleanup/templates/backup-docker-cleanup.service.j2 diff --git a/roles/docker-volume-backup-cleanup/vars/main.yml b/roles/backup-docker-cleanup/vars/main.yml similarity index 65% rename from roles/docker-volume-backup-cleanup/vars/main.yml rename to roles/backup-docker-cleanup/vars/main.yml index 68b958e8..1114eb23 100644 --- a/roles/docker-volume-backup-cleanup/vars/main.yml +++ b/roles/backup-docker-cleanup/vars/main.yml @@ -1 +1 @@ -docker_volume_backup_cleanup_folder: "{{path_administrator_scripts}}docker-volume-backup-cleanup/" \ No newline at end of file +docker_volume_backup_cleanup_folder: "{{path_administrator_scripts}}backup-docker-cleanup/" \ No newline at end of file diff --git a/roles/backup-docker/handlers/main.yml b/roles/backup-docker/handlers/main.yml new file mode 100644 index 00000000..7fbc05b0 --- /dev/null +++ b/roles/backup-docker/handlers/main.yml @@ -0,0 +1,12 @@ +- 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/docker-volume-backup/meta/main.yml b/roles/backup-docker/meta/main.yml similarity index 66% rename from roles/docker-volume-backup/meta/main.yml rename to roles/backup-docker/meta/main.yml index 36e85f8f..11e4c704 100644 --- a/roles/docker-volume-backup/meta/main.yml +++ b/roles/backup-docker/meta/main.yml @@ -2,4 +2,4 @@ dependencies: - git - backups-provider - systemd_notifier - - docker-volume-backup-cleanup \ No newline at end of file + - backup-docker-cleanup \ No newline at end of file diff --git a/roles/docker-volume-backup/tasks/main.yml b/roles/backup-docker/tasks/main.yml similarity index 56% rename from roles/docker-volume-backup/tasks/main.yml rename to roles/backup-docker/tasks/main.yml index 19909238..6fcbc0b0 100644 --- a/roles/docker-volume-backup/tasks/main.yml +++ b/roles/backup-docker/tasks/main.yml @@ -5,9 +5,9 @@ - python-pandas state: present -- name: pull docker-volume-backup.git +- name: pull backup-docker.git git: - repo: "https://github.com/kevinveenbirkenbach/docker-volume-backup.git" + repo: "https://github.com/kevinveenbirkenbach/backup-docker.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 docker-volume-backup.service +- name: configure backup-docker.service template: - src: docker-volume-backup.service.j2 - dest: /etc/systemd/system/docker-volume-backup.service - notify: reload docker-volume-backup.service + src: backup-docker.service.j2 + dest: /etc/systemd/system/backup-docker.service + notify: reload backup-docker.service -- name: configure docker-volume-backup.timer.tpl - template: src=docker-volume-backup.timer.j2 dest=/etc/systemd/system/docker-volume-backup.timer - notify: restart docker-volume-backup.timer +- 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: create {{docker_volume_backup_folder}}databases.csv copy: diff --git a/roles/backup-docker/templates/backup-docker.service.j2 b/roles/backup-docker/templates/backup-docker.service.j2 new file mode 100644 index 00000000..ade41073 --- /dev/null +++ b/roles/backup-docker/templates/backup-docker.service.j2 @@ -0,0 +1,7 @@ +[Unit] +Description=docker volume backup +OnFailure=systemd-notifier@%n.service backup-docker-cleanup.service + +[Service] +Type=oneshot +ExecStart=/usr/bin/python {{docker_volume_backup_folder}}backup-docker.py \ No newline at end of file diff --git a/roles/docker-volume-backup/templates/docker-volume-backup.timer.j2 b/roles/backup-docker/templates/backup-docker.timer.j2 similarity index 100% rename from roles/docker-volume-backup/templates/docker-volume-backup.timer.j2 rename to roles/backup-docker/templates/backup-docker.timer.j2 diff --git a/roles/backup-docker/vars/main.yml b/roles/backup-docker/vars/main.yml new file mode 100644 index 00000000..28847cf0 --- /dev/null +++ b/roles/backup-docker/vars/main.yml @@ -0,0 +1 @@ +docker_volume_backup_folder: "{{path_administrator_scripts}}backup-docker/" \ No newline at end of file diff --git a/roles/backups-consumer/meta/main.yml b/roles/backups-consumer/meta/main.yml index 9117c4cc..7508b80b 100644 --- a/roles/backups-consumer/meta/main.yml +++ b/roles/backups-consumer/meta/main.yml @@ -2,4 +2,4 @@ dependencies: - git - systemd_notifier - backups-cleanup-timer - - docker-volume-backup-cleanup + - backup-docker-cleanup diff --git a/roles/backups-consumer/templates/pull-remote-backups.service.j2 b/roles/backups-consumer/templates/pull-remote-backups.service.j2 index 3b091a46..396f081d 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 docker-volume-backup-cleanup.service +OnFailure=systemd-notifier@%n.service backup-docker-cleanup.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 6c8ae350..595af46e 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 docker-volume-backup are integrated, this logic needs to be optimized -get_version_directories="ls -d /Backups/$hashed_machine_id/docker-volume-backup/*" +# @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/*" last_version_directory="$($get_version_directories | tail -1)" rsync_command="sudo rsync --server --sender -blogDtpre.iLsfxCIvu . $last_version_directory/" diff --git a/roles/docker-akaunting/README.md b/roles/docker-akaunting/README.md index b1b55393..504d984e 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}}docker-volume-backup && +cd {{path_administrator_scripts}}backup-docker && 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 72da53fa..37ecc3e3 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 docker-volume-backup.service") + bash("systemctl is-active --quiet backup-docker.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 fa0a7592..12b76091 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)/docker-volume-backup/latest/nextcloud_database/sql/backup.sql" && -cd {{path_administrator_scripts}}docker-volume-backup && +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 && bash ./docker-volume-recover.sh "nextcloud_data" "$(sha256sum /etc/machine-id | head -c 64)" ``` diff --git a/roles/docker-volume-backup-cleanup/README.md b/roles/docker-volume-backup-cleanup/README.md deleted file mode 100644 index 949b269e..00000000 --- a/roles/docker-volume-backup-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/docker-volume-backup-cleanup as base. \ No newline at end of file diff --git a/roles/docker-volume-backup-cleanup/handlers/main.yml b/roles/docker-volume-backup-cleanup/handlers/main.yml deleted file mode 100644 index 367266d2..00000000 --- a/roles/docker-volume-backup-cleanup/handlers/main.yml +++ /dev/null @@ -1,5 +0,0 @@ -- name: "reload docker-volume-backup-cleanup.service daemon" - systemd: - name: docker-volume-backup-cleanup.service - enabled: yes - daemon_reload: yes diff --git a/roles/docker-volume-backup-cleanup/tasks/main.yml b/roles/docker-volume-backup-cleanup/tasks/main.yml deleted file mode 100644 index 33f8ac10..00000000 --- a/roles/docker-volume-backup-cleanup/tasks/main.yml +++ /dev/null @@ -1,18 +0,0 @@ -- name: pull docker-volume-backup-cleanup.git - git: - repo: "https://github.com/kevinveenbirkenbach/docker-volume-backup-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 docker-volume-backup-cleanup.service - template: - src: docker-volume-backup-cleanup.service.j2 - dest: /etc/systemd/system/docker-volume-backup-cleanup.service - notify: reload docker-volume-backup-cleanup.service daemon \ No newline at end of file diff --git a/roles/docker-volume-backup/handlers/main.yml b/roles/docker-volume-backup/handlers/main.yml deleted file mode 100644 index 217414e2..00000000 --- a/roles/docker-volume-backup/handlers/main.yml +++ /dev/null @@ -1,12 +0,0 @@ -- name: "reload docker-volume-backup.service" - systemd: - name: docker-volume-backup.service - enabled: yes - daemon_reload: yes - -- name: "restart docker-volume-backup.timer" - systemd: - name: docker-volume-backup.timer - state: started - enabled: yes - daemon_reload: yes diff --git a/roles/docker-volume-backup/templates/docker-volume-backup.service.j2 b/roles/docker-volume-backup/templates/docker-volume-backup.service.j2 deleted file mode 100644 index f5a82176..00000000 --- a/roles/docker-volume-backup/templates/docker-volume-backup.service.j2 +++ /dev/null @@ -1,7 +0,0 @@ -[Unit] -Description=docker volume backup -OnFailure=systemd-notifier@%n.service docker-volume-backup-cleanup.service - -[Service] -Type=oneshot -ExecStart=/usr/bin/python {{docker_volume_backup_folder}}docker-volume-backup.py \ No newline at end of file diff --git a/roles/docker-volume-backup/vars/main.yml b/roles/docker-volume-backup/vars/main.yml deleted file mode 100644 index 24f466b6..00000000 --- a/roles/docker-volume-backup/vars/main.yml +++ /dev/null @@ -1 +0,0 @@ -docker_volume_backup_folder: "{{path_administrator_scripts}}docker-volume-backup/" \ No newline at end of file diff --git a/roles/docker/meta/main.yml b/roles/docker/meta/main.yml index 1c90feff..31acbadc 100644 --- a/roles/docker/meta/main.yml +++ b/roles/docker/meta/main.yml @@ -1,5 +1,5 @@ dependencies: - - docker-volume-backup + - backup-docker - user-administrator - health-docker - docker-compose-restart-unhealthy