docker: add housekeeping #105

Merged
mg merged 12 commits from dhc into master 2024-06-05 18:58:29 +02:00
5 changed files with 65 additions and 21 deletions
Showing only changes of commit d7b52fb8de - Show all commits

View file

@ -0,0 +1,28 @@
---
- name: systemctl daemon-reload
become: true
ansible.builtin.systemd:
daemon_reload: true
- name: systemctl enable units
become: true
ansible.builtin.systemd:
name: "{{ item }}"
enabled: true
masked: false
with_items:
- media-docker_housekeeping.automount
- media-docker_housekeeping.mount
- docker_housekeeping.service
- docker_housekeeping.timer
- docker_housekeeping_mail.service
- name: systemctl start units
become: true
ansible.builtin.systemd:
name: "{{ item }}"
state: restarted
enabled: true
with_items:
- docker_housekeeping.timer
notify: systemctl daemon-reload

View file

@ -1,7 +1,23 @@
---
- name: Include LDAP tasks
ansible.builtin.include_tasks: ldap.yml
- name: template docker_housekeeping.service
become: true
ansible.builtin.template:
src: docker_housekeeping.service.j2
dest: /etc/systemd/system/docker_housekeeping.service
owner: root
group: root
mode: "0644"
notify:
- systemctl daemon-reload
- name: Include User tasks
ansible.builtin.include_tasks: admin.yml
- name: template docker_housekeeping.timer
become: true
ansible.builtin.template:
src: docker_housekeeping.timer.j2
dest: /etc/systemd/system/docker_housekeeping.timer
owner: root
group: root
mode: "0644"
notify:
- systemctl daemon-reload
...

View file

@ -0,0 +1,15 @@
{{ file_header | default () }}
[Unit]
Description=Backup with docker_housekeeping
Requires=media-docker_housekeeping.mount
After=media-docker_housekeeping.mount
OnFailure=docker_housekeeping_mail.service
[Service]
Type=simple
EnvironmentFile={{ docker_housekeeping_conf_dir }}/docker_housekeeping.env
ExecStart=/usr/bin/docker_housekeeping backup --one-file-system --no-cache --exclude-file {{ docker_housekeeping_conf_dir }}/excludes {{ docker_housekeeping_folders_to_backup }}
{# -iexclude-file Same as exclude-file but ignores cases like in --iexclude; https://docker_housekeeping.readthedocs.io/en/latest/040_backup.html #}
User={{ docker_housekeeping_user }}
Group={{ docker_housekeeping_group }}
RestartSec={{ docker_housekeeping_failure_delay }}

View file

@ -1,9 +1,9 @@
{{ file_header | default () }}
[Unit]
Description=Timer for restic backups.
Description=Timer for docker_housekeeping backups.
[Timer]
OnCalendar={{ restic_schedule }}
OnCalendar={{ docker_housekeeping_schedule }}
RandomizedDelaySec=30 min
[Install]

View file

@ -1,15 +0,0 @@
{{ file_header | default () }}
[Unit]
Description=Backup with restic
Requires=media-restic.mount
After=media-restic.mount
OnFailure=restic_mail.service
[Service]
Type=simple
EnvironmentFile={{ restic_conf_dir }}/restic.env
ExecStart=/usr/bin/restic backup --one-file-system --no-cache --exclude-file {{ restic_conf_dir }}/excludes {{ restic_folders_to_backup }}
{# -iexclude-file Same as exclude-file but ignores cases like in --iexclude; https://restic.readthedocs.io/en/latest/040_backup.html #}
User={{ restic_user }}
Group={{ restic_group }}
RestartSec={{ restic_failure_delay }}