summaryrefslogtreecommitdiff
path: root/roles/storage/zfs/syncoid/tasks/main.yml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/storage/zfs/syncoid/tasks/main.yml')
-rw-r--r--roles/storage/zfs/syncoid/tasks/main.yml54
1 files changed, 49 insertions, 5 deletions
diff --git a/roles/storage/zfs/syncoid/tasks/main.yml b/roles/storage/zfs/syncoid/tasks/main.yml
index a01900b1..6232eea7 100644
--- a/roles/storage/zfs/syncoid/tasks/main.yml
+++ b/roles/storage/zfs/syncoid/tasks/main.yml
@@ -43,8 +43,8 @@
loop_control:
label: "{{ item.key }}"
template:
- src: systemd.service.j2
- dest: "/etc/systemd/system/syncoid-{{ item.key }}.service"
+ src: pull.service.j2
+ dest: "/etc/systemd/system/syncoid-pull-{{ item.key }}.service"
- name: create systemd timer units for periodic backups
loop: "{{ zfs_syncoid_sources | dict2items }}"
@@ -52,8 +52,8 @@
label: "{{ item.key }}"
when: "'periodic' in item.value"
template:
- src: systemd.timer.j2
- dest: "/etc/systemd/system/syncoid-{{ item.key }}.timer"
+ src: pull.timer.j2
+ dest: "/etc/systemd/system/syncoid-pull-{{ item.key }}.timer"
- name: make sure systemd timer units for periodic backups are enabled and started
loop: "{{ zfs_syncoid_sources | dict2items }}"
@@ -62,6 +62,50 @@
when: "'periodic' in item.value"
systemd:
daemon_reload: yes
- name: "syncoid-{{ item.key }}.timer"
+ name: "syncoid-pull-{{ item.key }}.timer"
state: started
enabled: yes
+
+- name: enable autosuspend
+ when: zfs_syncoid_autosuspend
+ block:
+ - name: generate syncoid post script
+ copy:
+ content: |
+ #!/bin/bash
+
+ echo "running sanoid --prune to cleanup old snapshots"
+ sleep 5
+ systemctl start --wait sanoid-prune.service
+
+ echo "wait 60s (autosuspend cooldown period)"
+ sleep 60
+ echo "done."
+ dest: /var/lib/syncoid/syncoid_post
+ mode: 0755
+
+ - name: install python deps
+ apt:
+ name: "{{ python_basename }}-dbus"
+ state: present
+
+ - name: install autosuspend script
+ template:
+ src: autosuspend.py.j2
+ dest: /usr/local/bin/syncoid-autosuspend.py
+ mode: 0755
+
+ - name: install autosuspend systemd units
+ loop:
+ - service
+ - timer
+ template:
+ src: "autosuspend.{{ item }}.j2"
+ dest: "/etc/systemd/system/syncoid-autosuspend.{{ item }}"
+
+ - name: make sure autosuspend timer unit is enabled and started
+ systemd:
+ daemon_reload: yes
+ name: syncoid-autosuspend.timer
+ enabled: yes
+ state: started