Implemented cleanup procedure for failed backups

This commit is contained in:
Kevin Veen-Birkenbach 2023-11-04 14:36:55 +01:00
parent ebcd93f837
commit dfc0dbbffa
12 changed files with 44 additions and 6 deletions

View File

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

View File

@ -2,3 +2,4 @@ dependencies:
- git
- systemd_notifier
- backups-cleanup-timer
- docker-volume-backup-cleanup

View File

@ -1,6 +1,6 @@
[Unit]
Description=pull remote backups
OnFailure=systemd-notifier@%n.service
OnFailure=systemd-notifier@%n.service docker-volume-backup-cleanup.service
[Service]
Type=oneshot

View File

@ -0,0 +1,3 @@
# 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

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

View File

@ -0,0 +1,3 @@
dependencies:
- git
- systemd_notifier

View File

@ -0,0 +1,18 @@
- 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

@ -0,0 +1,7 @@
[Unit]
Description=Cleans up failed docker volume backups
OnFailure=systemd-notifier@%n.service
[Service]
Type=oneshot
ExecStart=/bin/sh -c '/usr/bin/yes | /usr/bin/bash {{docker_volume_backup_cleanup_folder}}cleanup.sh {{docker_volume_backup_cleanup_machine_id}} {{docker_volume_backup_cleanup_trigger_directory}}'

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
[Unit]
Description=docker volume backup
OnFailure=systemd-notifier@%n.service
OnFailure=systemd-notifier@%n.service docker-volume-backup-cleanup.service
[Service]
Type=oneshot