add restic prune job

This commit is contained in:
erebion 2024-08-16 20:26:27 +02:00
parent d1ae38cb3d
commit 64f4773c01
4 changed files with 45 additions and 0 deletions

View file

@ -7,3 +7,4 @@ APT_Periodic_Unattended_Upgrade: "1"
restic_repository_location: "sftp:restic_{{ inventory_hostname }}@proxmox.unhb.space:/storage/restic-backup/" restic_repository_location: "sftp:restic_{{ inventory_hostname }}@proxmox.unhb.space:/storage/restic-backup/"
restic_start_time: "*-*-* 1:00:00" restic_start_time: "*-*-* 1:00:00"
restic_prune_start_time: "*-*-* 11:00:00"

View file

@ -86,6 +86,17 @@
register: unit register: unit
when: "ansible_os_family == 'Debian'" when: "ansible_os_family == 'Debian'"
- name: "Template systemd units for restic"
ansible.builtin.template:
src: "restic-prune.service.j2"
dest: "/etc/systemd/system/restic-prune.service"
owner: root
group: root
mode: 'u+rw'
force: true
register: unit
when: "ansible_os_family == 'Debian'"
- name: "Template systemd timers for restic" - name: "Template systemd timers for restic"
ansible.builtin.template: ansible.builtin.template:
src: "restic.timer.j2" src: "restic.timer.j2"
@ -97,6 +108,17 @@
register: unit register: unit
when: "ansible_os_family == 'Debian'" when: "ansible_os_family == 'Debian'"
- name: "Template systemd timers for restic"
ansible.builtin.template:
src: "restic-prune.timer.j2"
dest: "/etc/systemd/system/restic-prune.timer"
owner: root
group: root
mode: 'u+rw'
force: true
register: unit
when: "ansible_os_family == 'Debian'"
- name: "Reload systemd units" - name: "Reload systemd units"
ansible.builtin.systemd: ansible.builtin.systemd:
daemon_reload: true daemon_reload: true
@ -109,6 +131,8 @@
with_items: with_items:
- "restic@{{ inventory_hostname }}.service" - "restic@{{ inventory_hostname }}.service"
- "restic@{{ inventory_hostname }}.timer" - "restic@{{ inventory_hostname }}.timer"
- "restic-prune.service"
- "restic-prune.timer"
when: unit.changed when: unit.changed
#- name: "Enable systemd units for restic-wasabi" #- name: "Enable systemd units for restic-wasabi"

View file

@ -0,0 +1,11 @@
[Unit]
Description=This unit will start pruning restic snapshots
After=
Wants=
[Service]
Restart=no
Type=simple
ExecStart=/opt/scripts/restic/restic-prune.sh
[Install]

View file

@ -0,0 +1,9 @@
[Unit]
Description=Timer starting restic-prune.service
[Timer]
OnCalendar={{ restic_prune_start_time }}
Unit=restic-prune.service
[Install]
WantedBy=multi-user.target