Compare commits

..

20 Commits

Author SHA1 Message Date
29f134005f Implemented -e "activate_all_timers=true" 2023-11-16 19:43:54 +01:00
333d1078f8 renamed to heal-docker 2023-11-16 18:42:39 +01:00
2170862d5f renamed to backup-remote-to-local 2023-11-16 17:55:54 +01:00
33bbd6a1df Renamed to backup and cleanup roles 2023-11-16 17:07:28 +01:00
3b3737dc33 Renamed to backup-docker 2023-11-16 16:55:16 +01:00
d2a728180f Removed ignore 2023-11-16 16:51:16 +01:00
334aa9989b Solved bugs 2023-11-16 16:40:45 +01:00
23ca62833f Updated Readme.md 2023-11-16 16:06:59 +01:00
9bd6de8043 Optimized ressources 2023-11-16 15:42:09 +01:00
51006074b4 Renamed health services 2023-11-16 15:32:29 +01:00
8d04397b91 Optimized docker update 2023-11-16 15:18:11 +01:00
41c1151f5a Optimized update routine 2023-11-16 15:13:34 +01:00
f237cf140c Catched error if no local images exist 2023-11-16 14:42:09 +01:00
f0e5c2caa4 Changed need to build logic 2023-11-16 14:33:06 +01:00
032ce50c77 Solved bug 2023-11-16 14:24:13 +01:00
40798d2294 optimized draft 2023-11-16 14:04:42 +01:00
9b0d744052 implemented an more general digest approach 2023-11-16 13:15:15 +01:00
4b32bd1e5d improved rebuild performance 2023-11-16 12:49:53 +01:00
407123492f Added python draft 2023-11-16 12:31:12 +01:00
10b04f8bd3 Added draft for update-docker 2023-11-16 12:26:27 +01:00
143 changed files with 665 additions and 461 deletions

View File

@ -30,12 +30,12 @@ This software allows to setup the docker following applications:
#### Native Applications #### Native Applications
This software shipts the following tools which are natively setup on the server: 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/btrfs-health-check/README.md) - Checks the health of Btrfs file systems - [Btrfs Health Check](./roles/health-btrfs/README.md) - Checks the health of Btrfs file systems
- [Docker Health Check](./roles/docker-health-check/) - Checks the health of docker containers - [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 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-to-local/) - Backup Solution for Docker Volumes
- [Pull Primary Backups](./roles/backups-consumer/README.md) - Pulls the backups from another server and stores them - [Pull Primary Backups](./roles/backup-remote-to-local/README.md) - Pulls the backups from another server and stores them
- [Wireguard](./roles/wireguard/README.md) - Integrates the server in an wireguard vpn - [Wireguard](./roles/wireguard/README.md) - Integrates the server in an wireguard vpn
### Server Administration ### Server Administration

View File

@ -3,7 +3,7 @@
hosts: all hosts: all
become: true become: true
roles: roles:
- system-update - update
- name: servers host setup - name: servers host setup
hosts: servers hosts: servers
@ -11,9 +11,9 @@
roles: roles:
- system-security - system-security
- journalctl - journalctl
- disc-space-check - health-disc-space
- free-disc-space - cleanup-disc-space
- btrfs-health-check - health-btrfs
# Wireguard Rollen # Wireguard Rollen
- name: setup standard wireguard - name: setup standard wireguard
@ -204,7 +204,7 @@
hosts: replica_backup hosts: replica_backup
become: true become: true
roles: roles:
- role: backups-consumer - role: backup-remote-to-local
## PC services ## PC services
- name: general host setup - name: general host setup
@ -321,4 +321,4 @@
hosts: backup_to_usb hosts: backup_to_usb
become: true become: true
roles: roles:
- backup-to-usb - backup-data-to-usb

View File

@ -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. This Ansible role automates the process of performing backups to a swappable USB device.

View File

@ -21,7 +21,7 @@ def main():
machine_id = subprocess.run(["sha256sum", "/etc/machine-id"], capture_output=True, text=True).stdout.strip()[:64] machine_id = subprocess.run(["sha256sum", "/etc/machine-id"], capture_output=True, text=True).stdout.strip()[:64]
print(f"machine id: {machine_id}") 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}") print(f"versions path: {versions_path}")
if not os.path.isdir(versions_path): if not os.path.isdir(versions_path):

View File

@ -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

View File

@ -0,0 +1,3 @@
---
dependencies:
- role: cleanup-backups-service

View File

@ -1,6 +1,6 @@
- name: Copy backup script to the scripts directory - name: Copy backup script to the scripts directory
copy: copy:
src: backup-to-usb.python src: backup-data-to-usb.python
dest: "{{ backup_to_usb_script_path }}" dest: "{{ backup_to_usb_script_path }}"
owner: root owner: root
group: root group: root
@ -8,9 +8,9 @@
- name: Copy systemd service to systemd directory - name: Copy systemd service to systemd directory
template: template:
src: backup-to-usb.service.j2 src: backup-data-to-usb.service.j2
dest: /etc/systemd/system/backup-to-usb.service dest: /etc/systemd/system/backup-data-to-usb.service
owner: root owner: root
group: root group: root
mode: '0644' mode: '0644'
notify: reload backup-to-usb.service notify: reload backup-data-to-usb.service

View File

@ -5,7 +5,7 @@ OnFailure=systemd-notifier@%n.service
[Service] [Service]
ExecStart=/bin/python {{ backup_to_usb_script_path }} {{backup_to_usb_source}} {{backup_to_usb_destination}} ExecStart=/bin/python {{ backup_to_usb_script_path }} {{backup_to_usb_source}} {{backup_to_usb_destination}}
ExecStartPost=/bin/systemctl start backups-cleanup.service ExecStartPost=/bin/systemctl start cleanup-backups.service
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View File

@ -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}}" backup_to_usb_destination: "{{backup_to_usb_mount}}{{backup_to_usb_destination_subdirectory}}"
backups_folder_path: "{{backup_to_usb_destination}}" backups_folder_path: "{{backup_to_usb_destination}}"
systemctl_mount_service_name: "{{ backup_to_usb_mount | trim('/') | replace('/', '-') }}.mount" systemctl_mount_service_name: "{{ backup_to_usb_mount | trim('/') | replace('/', '-') }}.mount"

View File

@ -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

View File

@ -2,4 +2,4 @@ dependencies:
- git - git
- backups-provider - backups-provider
- systemd_notifier - systemd_notifier
- docker-volume-backup-cleanup - cleanup-failed-docker-backups

View File

@ -0,0 +1,38 @@
- name: install pandas system wide
community.general.pacman:
name:
- lsof
- python-pandas
state: present
- name: pull backup-docker-to-local.git
git:
repo: "https://github.com/kevinveenbirkenbach/backup-docker-to-local.git"
dest: "{{docker_volume_backup_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-to-local.service
template:
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-to-local.timer.tpl
template: src=backup-docker-to-local.timer.j2 dest=/etc/systemd/system/backup-docker-to-local.timer
register: backup_docker_to_local_timer
changed_when: backup_docker_to_local_timer.changed or activate_all_timers | default(false) | bool
notify: restart backup-docker-to-local.timer
- name: create {{docker_volume_backup_folder}}databases.csv
copy:
src: "{{ inventory_dir }}/files/{{ inventory_hostname }}{{docker_volume_backup_folder}}databases.csv"
dest: "{{docker_volume_backup_folder}}databases.csv"
owner: root
group: root

View File

@ -0,0 +1,7 @@
[Unit]
Description=docker volume backup
OnFailure=systemd-notifier@%n.service cleanup-failed-docker-backups.service
[Service]
Type=oneshot
ExecStart=/usr/bin/python {{docker_volume_backup_folder}}backup-docker-to-local.py

View File

@ -0,0 +1 @@
docker_volume_backup_folder: "{{path_administrator_scripts}}backup-docker-to-local/"

View File

@ -1,4 +1,4 @@
# role backups-consumer # role backup-remote-to-local
## goal ## goal
This script allows to pull backups from a remote server. This script allows to pull backups from a remote server.
@ -15,17 +15,17 @@ To track what the service is doing execute one of the following commands:
#### systemctl #### systemctl
```bash ```bash
watch -n2 "systemctl status pull-remote-backups.service" watch -n2 "systemctl status backup-remote-to-local.service"
``` ```
#### journalctl #### journalctl
```bash ```bash
journalctl -fu pull-remote-backups.service journalctl -fu backup-remote-to-local.service
``` ```
### history ### history
```bash ```bash
sudo journalctl -u pull-remote-backups sudo journalctl -u backup-remote-to-local
``` ```
## see ## see

View File

@ -0,0 +1,11 @@
- name: "reload backup-remote-to-local service"
systemd:
name: backup-remote-to-local.service
enabled: yes
daemon_reload: yes
- name: "restart backup-remote-to-local timer"
systemd:
name: backup-remote-to-local.timer
state: started
enabled: yes
daemon_reload: yes

View File

@ -0,0 +1,5 @@
dependencies:
- git
- systemd_notifier
- cleanup-backups-timer
- cleanup-failed-docker-backups

View File

@ -0,0 +1,28 @@
- name: "create {{docker_pull_primary_backups_folder}}"
file:
path: "{{docker_pull_primary_backups_folder}}"
state: directory
mode: 0755
- name: create backup-remote-to-local.sh
copy:
src: backup-remote-to-local.sh
dest: "{{docker_pull_primary_backups_folder}}backup-remote-to-local.sh"
mode: 0755
- name: create backup-remote-to-local.service
template: src=backup-remote-to-local.service.j2 dest=/etc/systemd/system/backup-remote-to-local.service
notify: reload backup-remote-to-local service
- name: create backup-remote-to-local.timer
template: src=backup-remote-to-local.timer.j2 dest=/etc/systemd/system/backup-remote-to-local.timer
register: backup_remote_to_local_timer
changed_when: backup_remote_to_local_timer.changed or activate_all_timers | default(false) | bool
notify: restart backup-remote-to-local timer
- name: create backup-remote-to-local.sh
template:
src: backup-remote-to-local.sh.j2
dest: "{{docker_pull_primary_backups_folder}}backup-remote-to-local.sh"
mode: 0755

View File

@ -0,0 +1,7 @@
[Unit]
Description=pull remote backups
OnFailure=systemd-notifier@%n.service cleanup-failed-docker-backups.service
[Service]
Type=oneshot
ExecStart=/usr/bin/bash {{docker_pull_primary_backups_folder}}backup-remote-to-local.sh

View File

@ -3,6 +3,6 @@
hosts="{{pull_remote_backups}}"; hosts="{{pull_remote_backups}}";
errors=0 errors=0
for host in $hosts; do for host in $hosts; do
bash {{docker_pull_primary_backups_folder}}pull-remote-backup.sh $host || ((errors+=1)); bash {{docker_pull_primary_backups_folder}}backup-remote-to-local.sh $host || ((errors+=1));
done; done;
exit $errors; exit $errors;

View File

@ -1,6 +0,0 @@
- name: "reload backup-to-usb.service"
systemd:
name: backup-to-usb.service
state: reloaded
enabled: yes
daemon_reload: yes

View File

@ -1,3 +0,0 @@
---
dependencies:
- role: backups-cleanup-service

View File

@ -1,6 +0,0 @@
- name: "reload backups-cleanup.service"
systemd:
name: backups-cleanup.service
state: reloaded
enabled: yes
daemon_reload: yes

View File

@ -1,23 +0,0 @@
- name: install lsof and python-psutil
community.general.pacman:
name:
- lsof
- python-psutil
state: present
- name: "create {{docker_backups_cleanup}}"
file:
path: "{{docker_backups_cleanup}}"
state: directory
mode: 0755
- name: create backups-cleanup.py
copy:
src: "backups-cleanup.py"
dest: "{{docker_backups_cleanup}}backups-cleanup.py"
- name: create backups-cleanup.service
template:
src: "backups-cleanup.service.j2"
dest: "/etc/systemd/system/backups-cleanup.service"
notify: reload backups-cleanup.service

View File

@ -1 +0,0 @@
docker_backups_cleanup: "{{path_administrator_scripts}}backups-cleanup/"

View File

@ -1,2 +0,0 @@
dependencies:
- backups-cleanup-service

View File

@ -1,5 +0,0 @@
- name: create backups-cleanup.timer
template:
src: "backups-cleanup.timer.j2"
dest: "/etc/systemd/system/backups-cleanup.timer"
notify: restart backups-cleanup.timer

View File

@ -1,11 +0,0 @@
- name: "reload pull-remote-backups service"
systemd:
name: pull-remote-backups.service
enabled: yes
daemon_reload: yes
- name: "restart pull-remote-backups timer"
systemd:
name: pull-remote-backups.timer
state: started
enabled: yes
daemon_reload: yes

View File

@ -1,5 +0,0 @@
dependencies:
- git
- systemd_notifier
- backups-cleanup-timer
- docker-volume-backup-cleanup

View File

@ -1,26 +0,0 @@
- name: "create {{docker_pull_primary_backups_folder}}"
file:
path: "{{docker_pull_primary_backups_folder}}"
state: directory
mode: 0755
- name: create pull-remote-backup.sh
copy:
src: pull-remote-backup.sh
dest: "{{docker_pull_primary_backups_folder}}pull-remote-backup.sh"
mode: 0755
- name: create pull-remote-backups.service
template: src=pull-remote-backups.service.j2 dest=/etc/systemd/system/pull-remote-backups.service
notify: reload pull-remote-backups service
- name: create pull-remote-backups.timer
template: src=pull-remote-backups.timer.j2 dest=/etc/systemd/system/pull-remote-backups.timer
notify: restart pull-remote-backups timer
- name: create pull-remote-backups.sh
template:
src: pull-remote-backups.sh.j2
dest: "{{docker_pull_primary_backups_folder}}pull-remote-backups.sh"
mode: 0755

View File

@ -1,7 +0,0 @@
[Unit]
Description=pull remote backups
OnFailure=systemd-notifier@%n.service docker-volume-backup-cleanup.service
[Service]
Type=oneshot
ExecStart=/usr/bin/bash {{docker_pull_primary_backups_folder}}pull-remote-backups.sh

View File

@ -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 {} ;"; 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 # @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/docker-volume-backup/*" get_version_directories="ls -d /Backups/$hashed_machine_id/backup-docker-to-local/*"
last_version_directory="$($get_version_directories | tail -1)" last_version_directory="$($get_version_directories | tail -1)"
rsync_command="sudo rsync --server --sender -blogDtpre.iLsfxCIvu . $last_version_directory/" rsync_command="sudo rsync --server --sender -blogDtpre.iLsfxCIvu . $last_version_directory/"

View File

@ -1,3 +1,3 @@
dependencies: dependencies:
- backups-provider-user - backups-provider-user
- backups-cleanup-timer - cleanup-backups-timer

View File

@ -1,12 +0,0 @@
- name: "reload btrfs-health-check.service"
systemd:
name: btrfs-health-check.service
state: reloaded
enabled: yes
daemon_reload: yes
- name: "restart btrfs-health-check.timer"
systemd:
name: btrfs-health-check.timer
state: restarted
enabled: yes
daemon_reload: yes

View File

@ -1,22 +0,0 @@
- name: "create {{docker_btrfs_health_check_folder}}"
file:
path: "{{docker_btrfs_health_check_folder}}"
state: directory
mode: 0755
- name: create btrfs-health-check.sh
copy:
src: btrfs-health-check.sh
dest: "{{docker_btrfs_health_check_folder}}btrfs-health-check.sh"
- name: create btrfs-health-check.service
template:
src: btrfs-health-check.service.j2
dest: /etc/systemd/system/btrfs-health-check.service
notify: reload btrfs-health-check.service
- name: create btrfs-health-check.timer
template:
src: btrfs-health-check.timer.j2
dest: "/etc/systemd/system/btrfs-health-check.timer"
notify: restart btrfs-health-check.timer

View File

@ -13,4 +13,6 @@
template: template:
src: certbot.timer.j2 src: certbot.timer.j2
dest: /etc/systemd/system/certbot.timer dest: /etc/systemd/system/certbot.timer
register: certbot_timer
changed_when: certbot_timer.changed or activate_all_timers | default(false) | bool
notify: restart certbot timer notify: restart certbot timer

View File

@ -1,4 +1,4 @@
# role backups-cleanup-timer # role cleanup-backups-timer
Cleans up old backups Cleans up old backups

View File

@ -0,0 +1,6 @@
- name: "reload cleanup-backups.service"
systemd:
name: cleanup-backups.service
state: reloaded
enabled: yes
daemon_reload: yes

View File

@ -0,0 +1,23 @@
- name: install lsof and python-psutil
community.general.pacman:
name:
- lsof
- python-psutil
state: present
- name: "create {{docker_backups_cleanup}}"
file:
path: "{{docker_backups_cleanup}}"
state: directory
mode: 0755
- name: create cleanup-backups.py
copy:
src: "cleanup-backups.py"
dest: "{{docker_backups_cleanup}}cleanup-backups.py"
- name: create cleanup-backups.service
template:
src: "cleanup-backups.service.j2"
dest: "/etc/systemd/system/cleanup-backups.service"
notify: reload cleanup-backups.service

View File

@ -4,4 +4,4 @@ OnFailure=systemd-notifier@%n.service
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=/usr/bin/python {{docker_backups_cleanup}}backups-cleanup.py --backups-folder-path {{backups_folder_path}} --maximum-backup-size-percent {{size_percent_maximum_backup}} ExecStart=/usr/bin/python {{docker_backups_cleanup}}cleanup-backups.py --backups-folder-path {{backups_folder_path}} --maximum-backup-size-percent {{size_percent_maximum_backup}}

View File

@ -0,0 +1 @@
docker_backups_cleanup: "{{path_administrator_scripts}}cleanup-backups/"

View File

@ -1,3 +1,3 @@
# role backups-cleanup-timer # role cleanup-backups-timer
Timer for cleaning up old backups Timer for cleaning up old backups

View File

@ -1,6 +1,6 @@
- name: "restart backups-cleanup.timer" - name: "restart cleanup-backups.timer"
systemd: systemd:
name: backups-cleanup.timer name: cleanup-backups.timer
state: restarted state: restarted
enabled: yes enabled: yes
daemon_reload: yes daemon_reload: yes

View File

@ -0,0 +1,2 @@
dependencies:
- cleanup-backups-service

View File

@ -0,0 +1,7 @@
- name: create cleanup-backups.timer
template:
src: "cleanup-backups.timer.j2"
dest: "/etc/systemd/system/cleanup-backups.timer"
register: cleanup_backups_timer
changed_when: cleanup_backups_timer.changed or activate_all_timers | default(false) | bool
notify: restart cleanup-backups.timer

View File

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=starts backups-cleanup.service Description=starts cleanup-backups.service
[Timer] [Timer]
OnCalendar={{on_calendar_backups_cleanup}} OnCalendar={{on_calendar_backups_cleanup}}

View File

@ -1,4 +1,4 @@
# free-disc-space # cleanup-disc-space
Frees disc space Frees disc space
## More information ## More information
- https://askubuntu.com/questions/380238/how-to-clean-tmp - https://askubuntu.com/questions/380238/how-to-clean-tmp

View File

@ -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

View File

@ -0,0 +1,24 @@
- 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
register: cleanup_disc_space_timer
changed_when: cleanup_disc_space_timer.changed or activate_all_timers | default(false) | bool
notify: restart cleanup-disc-space.timer

View File

@ -4,4 +4,4 @@ OnFailure=systemd-notifier@%n.service
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=/bin/bash {{free_disc_space_folder}}free-disc-space.sh {{size_percent_free_disc_space}} ExecStart=/bin/bash {{free_disc_space_folder}}cleanup-disc-space.sh {{size_percent_free_disc_space}}

View File

@ -25,7 +25,7 @@ if [ "$disc_use_percent_number" -gt "$minimum_percent_free_disc_space" ] || [ "$
{% if backups_folder_path is defined and size_percent_maximum_backup is defined %} {% if backups_folder_path is defined and size_percent_maximum_backup is defined %}
echo "cleaning up backups" && echo "cleaning up backups" &&
python {{path_administrator_scripts}}backups-cleanup/backups-cleanup.py --backups-folder-path {{backups_folder_path}} --maximum-backup-size-percent {{size_percent_maximum_backup}} || exit 2 python {{path_administrator_scripts}}cleanup-backups/cleanup-backups.py --backups-folder-path {{backups_folder_path}} --maximum-backup-size-percent {{size_percent_maximum_backup}} || exit 2
{% endif %} {% endif %}
if pacman -Qs $package > /dev/null ; then if pacman -Qs $package > /dev/null ; then

View File

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=starts free-disc-space.service Description=starts cleanup-disc-space.service
[Timer] [Timer]
OnCalendar={{on_calendar_free_disc_space}} OnCalendar={{on_calendar_free_disc_space}}

View File

@ -0,0 +1 @@
free_disc_space_folder: "{{path_administrator_scripts}}cleanup-disc-space/"

View File

@ -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.

View File

@ -0,0 +1,5 @@
- name: "reload cleanup-failed-docker-backups.service daemon"
systemd:
name: cleanup-failed-docker-backups.service
enabled: yes
daemon_reload: yes

View File

@ -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

View File

@ -1 +1 @@
docker_volume_backup_cleanup_folder: "{{path_administrator_scripts}}docker-volume-backup-cleanup/" docker_volume_backup_cleanup_folder: "{{path_administrator_scripts}}cleanup-failed-docker-backups/"

View File

@ -1,12 +0,0 @@
- name: "reload disc-space-check.service"
systemd:
name: disc-space-check.service
state: reloaded
enabled: yes
daemon_reload: yes
- name: "restart disc-space-check.timer"
systemd:
name: disc-space-check.timer
state: restarted
enabled: yes
daemon_reload: yes

View File

@ -1,22 +0,0 @@
- name: "create {{disc_space_check_folder}}"
file:
path: "{{disc_space_check_folder}}"
state: directory
mode: 0755
- name: create disc-space-check.sh
copy:
src: disc-space-check.sh
dest: "{{disc_space_check_folder}}disc-space-check.sh"
- name: create disc-space-check.service
template:
src: disc-space-check.service.j2
dest: /etc/systemd/system/disc-space-check.service
notify: reload disc-space-check.service
- name: create disc-space-check.timer
template:
src: disc-space-check.timer.j2
dest: /etc/systemd/system/disc-space-check.timer
notify: restart disc-space-check.timer

View File

@ -1,7 +0,0 @@
[Unit]
Description=checking disc space
OnFailure=systemd-notifier@%n.service
[Service]
Type=oneshot
ExecStart=/bin/bash {{disc_space_check_folder}}disc-space-check.sh {{size_percent_disc_space_warning}}

View File

@ -1 +0,0 @@
disc_space_check_folder: "{{path_administrator_scripts}}disc-space-check/"

View File

@ -81,7 +81,7 @@ docker-compose build &&
docker-compose -p akaunting up -d --force-recreate docker-compose -p akaunting up -d --force-recreate
# recover all volumes # recover all volumes
cd {{path_administrator_scripts}}docker-volume-backup && 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-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-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 bash docker-volume-recover.sh akaunting_akaunting-db ${machine_id:0:64} "$backup_version" akaunting-db "$akaunting_db_password" akaunting

View File

@ -1,12 +0,0 @@
- name: "reload docker-compose-restart-unhealthy.service"
systemd:
name: docker-compose-restart-unhealthy.service
state: reloaded
enabled: yes
daemon_reload: yes
- name: "restart docker-compose-restart-unhealthy.timer"
systemd:
name: docker-compose-restart-unhealthy.timer
state: restarted
enabled: yes
daemon_reload: yes

View File

@ -1,22 +0,0 @@
- name: "create {{docker_compose_restart_unhealthy}}"
file:
path: "{{docker_compose_restart_unhealthy}}"
state: directory
mode: 0755
- name: create docker-compose-restart-unhealthy.py
copy:
src: docker-compose-restart-unhealthy.py
dest: "{{docker_compose_restart_unhealthy}}docker-compose-restart-unhealthy.py"
- name: create docker-compose-restart-unhealthy.service
template:
src: docker-compose-restart-unhealthy.service.j2
dest: /etc/systemd/system/docker-compose-restart-unhealthy.service
notify: reload docker-compose-restart-unhealthy.service
- name: create docker-compose-restart-unhealthy.timer
template:
src: docker-compose-restart-unhealthy.timer.j2
dest: "/etc/systemd/system/docker-compose-restart-unhealthy.timer"
notify: restart docker-compose-restart-unhealthy.timer

View File

@ -1,12 +0,0 @@
- name: "reload docker-health-check.service"
systemd:
name: docker-health-check.service
state: reloaded
enabled: yes
daemon_reload: yes
- name: "restart docker-health-check.timer"
systemd:
name: docker-health-check.timer
state: restarted
enabled: yes
daemon_reload: yes

View File

@ -1,20 +0,0 @@
- name: "create {{docker_health_check_folder}}"
file:
path: "{{docker_health_check_folder}}"
state: directory
mode: 0755
- name: create docker-health-check.sh
copy:
src: docker-health-check.sh
dest: "{{docker_health_check_folder}}docker-health-check.sh"
- name: create docker-health-check.service
template: src=docker-health-check.service.j2 dest=/etc/systemd/system/docker-health-check.service
notify: reload docker-health-check.service
- name: create docker-health-check.timer
template:
src: docker-health-check.timer.j2
dest: "/etc/systemd/system/docker-health-check.timer"
notify: restart docker-health-check.timer

View File

@ -1 +0,0 @@
docker_health_check_folder: "{{path_administrator_scripts}}docker-health-check/"

View File

@ -60,4 +60,6 @@
template: template:
src: "deploy-letsencrypt-mailu.timer.j2" src: "deploy-letsencrypt-mailu.timer.j2"
dest: "/etc/systemd/system/deploy-letsencrypt-mailu.timer" dest: "/etc/systemd/system/deploy-letsencrypt-mailu.timer"
register: deploy_letsencrypt_mailu_timer
changed_when: deploy_letsencrypt_mailu_timer.changed or activate_all_timers | default(false) | bool
notify: restart deploy-letsencrypt-mailu.timer notify: restart deploy-letsencrypt-mailu.timer

View File

@ -59,8 +59,8 @@ and disable the not functioning apps.
```bash ```bash
cd {{path_docker_compose_files}}nextcloud && cd {{path_docker_compose_files}}nextcloud &&
docker-compose down && 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" && 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}}docker-volume-backup && cd {{path_administrator_scripts}}backup-docker-to-local &&
bash ./docker-volume-recover.sh "nextcloud_data" "$(sha256sum /etc/machine-id | head -c 64)" bash ./docker-volume-recover.sh "nextcloud_data" "$(sha256sum /etc/machine-id | head -c 64)"
``` ```

View File

@ -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.

View File

@ -1,5 +0,0 @@
- name: "reload docker-volume-backup-cleanup.service daemon"
systemd:
name: docker-volume-backup-cleanup.service
enabled: yes
daemon_reload: yes

View File

@ -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

View File

@ -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

View File

@ -1,36 +0,0 @@
- name: install pandas system wide
community.general.pacman:
name:
- lsof
- python-pandas
state: present
- name: pull docker-volume-backup.git
git:
repo: "https://github.com/kevinveenbirkenbach/docker-volume-backup.git"
dest: "{{docker_volume_backup_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.service
template:
src: docker-volume-backup.service.j2
dest: /etc/systemd/system/docker-volume-backup.service
notify: reload docker-volume-backup.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: create {{docker_volume_backup_folder}}databases.csv
copy:
src: "{{ inventory_dir }}/files/{{ inventory_hostname }}{{docker_volume_backup_folder}}databases.csv"
dest: "{{docker_volume_backup_folder}}databases.csv"
owner: root
group: root

View File

@ -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

View File

@ -1 +0,0 @@
docker_volume_backup_folder: "{{path_administrator_scripts}}docker-volume-backup/"

View File

@ -1,5 +1,5 @@
dependencies: dependencies:
- docker-volume-backup - backup-docker-to-local
- user-administrator - user-administrator
- docker-health-check - health-docker
- docker-compose-restart-unhealthy - heal-docker

View File

@ -1,4 +1,5 @@
--- ---
- name: docker & docker compose install - name: docker & docker compose install
pacman: pacman:
name: ['docker','docker-compose'] name: ['docker','docker-compose']

View File

@ -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

View File

@ -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

View File

@ -1 +0,0 @@
free_disc_space_folder: "{{path_administrator_scripts}}free-disc-space/"

View File

@ -1,2 +1,2 @@
# docker-compose-restart-unhealthy # heal-docker
docker-compose restart for containers which are unhealty or excited docker-compose restart for containers which are unhealty or excited

View File

@ -27,16 +27,17 @@ def print_bash(command):
return output return output
waiting_time=600 waiting_time=600
backup_running=True blocker_running=True
while backup_running: while blocker_running:
try: try:
bash("systemctl is-active --quiet docker-volume-backup.service") bash("systemctl is-active --quiet backup-docker-to-local.service")
bash("systemctl is-active --quiet update-docker.service")
print("backup is running.") print("backup is running.")
print("trying again in " + str(waiting_time) + " seconds.") print("trying again in " + str(waiting_time) + " seconds.")
time.sleep(waiting_time) time.sleep(waiting_time)
except: except:
backup_running=False blocker_running=False
print("no backup is running.") print("No blocking service is running.")
unhealthy_container_names=print_bash('docker ps --filter health=unhealthy --format \'{{.Names}}\'') unhealthy_container_names=print_bash('docker ps --filter health=unhealthy --format \'{{.Names}}\'')
exited_container_names=print_bash('docker ps --filter status=exited --format \'{{.Names}}\'') exited_container_names=print_bash('docker ps --filter status=exited --format \'{{.Names}}\'')

View File

@ -0,0 +1,12 @@
- name: "reload heal-docker.service"
systemd:
name: heal-docker.service
state: reloaded
enabled: yes
daemon_reload: yes
- name: "restart heal-docker.timer"
systemd:
name: heal-docker.timer
state: restarted
enabled: yes
daemon_reload: yes

View File

@ -0,0 +1,24 @@
- name: "create {{docker_compose_restart_unhealthy}}"
file:
path: "{{docker_compose_restart_unhealthy}}"
state: directory
mode: 0755
- name: create heal-docker.py
copy:
src: heal-docker.py
dest: "{{docker_compose_restart_unhealthy}}heal-docker.py"
- name: create heal-docker.service
template:
src: heal-docker.service.j2
dest: /etc/systemd/system/heal-docker.service
notify: reload heal-docker.service
- name: create heal-docker.timer
template:
src: heal-docker.timer.j2
dest: "/etc/systemd/system/heal-docker.timer"
register: heal_docker_timer
changed_when: heal_docker_timer.changed or activate_all_timers | default(false) | bool
notify: restart heal-docker.timer

View File

@ -4,4 +4,4 @@ OnFailure=systemd-notifier@%n.service
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=/bin/python {{docker_compose_restart_unhealthy}}docker-compose-restart-unhealthy.py ExecStart=/bin/python {{docker_compose_restart_unhealthy}}heal-docker.py

View File

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=starts docker-compose-restart-unhealthy.service Description=starts heal-docker.service
[Timer] [Timer]
OnCalendar={{on_calendar_docker_compose_restart_unhealthy}} OnCalendar={{on_calendar_docker_compose_restart_unhealthy}}

View File

@ -1 +1 @@
docker_compose_restart_unhealthy: "{{path_administrator_scripts}}docker-compose-restart-unhealthy/" docker_compose_restart_unhealthy: "{{path_administrator_scripts}}heal-docker/"

View File

@ -1,4 +1,4 @@
# btrfs-health-check # health-btrfs
Sends a health report Sends a health report

View File

@ -0,0 +1,12 @@
- name: "reload health-btrfs.service"
systemd:
name: health-btrfs.service
state: reloaded
enabled: yes
daemon_reload: yes
- name: "restart health-btrfs.timer"
systemd:
name: health-btrfs.timer
state: restarted
enabled: yes
daemon_reload: yes

Some files were not shown because too many files have changed in this diff Show More