From a23e7f8055818a1d95b005998f094a249f71b490 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 19 May 2021 18:55:24 +0200 Subject: syncoid: autosuspend cleanup and cooldown --- roles/storage/zfs/syncoid/tasks/main.yml | 15 +++++++++++++++ roles/storage/zfs/syncoid/templates/run.service.j2 | 3 +++ 2 files changed, 18 insertions(+) (limited to 'roles/storage') diff --git a/roles/storage/zfs/syncoid/tasks/main.yml b/roles/storage/zfs/syncoid/tasks/main.yml index 7c489baa..bab61a89 100644 --- a/roles/storage/zfs/syncoid/tasks/main.yml +++ b/roles/storage/zfs/syncoid/tasks/main.yml @@ -69,6 +69,21 @@ - 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 autosuspend script template: src: autosuspend.py.j2 diff --git a/roles/storage/zfs/syncoid/templates/run.service.j2 b/roles/storage/zfs/syncoid/templates/run.service.j2 index 0d214595..33283576 100644 --- a/roles/storage/zfs/syncoid/templates/run.service.j2 +++ b/roles/storage/zfs/syncoid/templates/run.service.j2 @@ -6,6 +6,9 @@ Type=oneshot {% for path,config in item.value.paths.items() %} ExecStart=/var/lib/syncoid/syncoid_wrapper --dumpsnaps --quiet {{ config.recursive | default(false) | ternary('-r ', '') }}{{ config.skip_parent | default(false) | ternary('--skip-parent ', '') }}{% for re in config.exclude | default([]) %}--exclude='{{ re }}' {% endfor %}{% if 'ssh_port' in item.value %}--sshport {{ item.value.ssh_port }} {% endif %}root@{{ item.value.ssh_hostname }}:{{ path }} {{ zfs_syncoid_target_pool }}/{{ item.key }}/{{ path }} {% endfor %} +{% if zfs_syncoid_autosuspend %} +ExecStart=/var/lib/syncoid/syncoid_post +{% endif %} {% if 'periodic' in item.value %} TimeoutStartSec={{ item.value.periodic.timeout }} {% endif %} -- cgit v1.2.3