summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2021-05-02 16:45:47 +0200
committerChristian Pointner <equinox@spreadspace.org>2021-05-02 16:45:47 +0200
commitfd1363eedadb183c439a00e143fd05ba8e10ad31 (patch)
tree8761cca63cdedcd5d0772bea48ac69262ca71f16
parentadapt backup sanoid template for ch-epimetheus only (diff)
add timer for syncoid backups
-rw-r--r--inventory/host_vars/ch-epimetheus.yml3
-rw-r--r--roles/storage/zfs/syncoid/defaults/main.yml3
-rw-r--r--roles/storage/zfs/syncoid/tasks/main.yml20
-rw-r--r--roles/storage/zfs/syncoid/templates/systemd.service.j23
-rw-r--r--roles/storage/zfs/syncoid/templates/systemd.timer.j28
-rw-r--r--spreadspace/sgg-icecast.yml2
6 files changed, 38 insertions, 1 deletions
diff --git a/inventory/host_vars/ch-epimetheus.yml b/inventory/host_vars/ch-epimetheus.yml
index 7b7bc457..6065f6c5 100644
--- a/inventory/host_vars/ch-epimetheus.yml
+++ b/inventory/host_vars/ch-epimetheus.yml
@@ -74,6 +74,9 @@ zfs_syncoid_sources:
'ch-prometheus':
ssh_hostname: "{{ network_zones.lan.prefix | ipaddr(network_zones.lan.offsets['ch-prometheus']) | ipaddr('address') }}"
ssh_port: "{{ hostvars['ch-prometheus'].ansible_port }}"
+ periodic:
+ schedule: "*-*-* 00,06,12,18:30:00"
+ timeout: 5h
paths:
nvme/vm:
recursive: yes
diff --git a/roles/storage/zfs/syncoid/defaults/main.yml b/roles/storage/zfs/syncoid/defaults/main.yml
index cdc58750..6e874daf 100644
--- a/roles/storage/zfs/syncoid/defaults/main.yml
+++ b/roles/storage/zfs/syncoid/defaults/main.yml
@@ -5,6 +5,9 @@
# somehost:
# ssh_hostname: 192.0.2.0
# ssh_port: 222
+# periodic: # optional
+# schedule: "*-*-* 01,13:30:00"
+# timeout: 8h
# paths:
# nvme/vm:
# recursive: yes
diff --git a/roles/storage/zfs/syncoid/tasks/main.yml b/roles/storage/zfs/syncoid/tasks/main.yml
index 53aa434a..a01900b1 100644
--- a/roles/storage/zfs/syncoid/tasks/main.yml
+++ b/roles/storage/zfs/syncoid/tasks/main.yml
@@ -45,3 +45,23 @@
template:
src: systemd.service.j2
dest: "/etc/systemd/system/syncoid-{{ item.key }}.service"
+
+- name: create systemd timer units for periodic backups
+ loop: "{{ zfs_syncoid_sources | dict2items }}"
+ loop_control:
+ label: "{{ item.key }}"
+ when: "'periodic' in item.value"
+ template:
+ src: systemd.timer.j2
+ dest: "/etc/systemd/system/syncoid-{{ item.key }}.timer"
+
+- name: make sure systemd timer units for periodic backups are enabled and started
+ loop: "{{ zfs_syncoid_sources | dict2items }}"
+ loop_control:
+ label: "{{ item.key }}"
+ when: "'periodic' in item.value"
+ systemd:
+ daemon_reload: yes
+ name: "syncoid-{{ item.key }}.timer"
+ state: started
+ enabled: yes
diff --git a/roles/storage/zfs/syncoid/templates/systemd.service.j2 b/roles/storage/zfs/syncoid/templates/systemd.service.j2
index ada34336..0d214595 100644
--- a/roles/storage/zfs/syncoid/templates/systemd.service.j2
+++ b/roles/storage/zfs/syncoid/templates/systemd.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 'periodic' in item.value %}
+TimeoutStartSec={{ item.value.periodic.timeout }}
+{% endif %}
PrivateTmp=yes
ProtectHome=yes
ProtectKernelTunables=yes
diff --git a/roles/storage/zfs/syncoid/templates/systemd.timer.j2 b/roles/storage/zfs/syncoid/templates/systemd.timer.j2
new file mode 100644
index 00000000..260a8938
--- /dev/null
+++ b/roles/storage/zfs/syncoid/templates/systemd.timer.j2
@@ -0,0 +1,8 @@
+[Unit]
+Description=syncoid-based backup for {{ item.key }}
+
+[Timer]
+OnCalendar={{ item.value.periodic.schedule }}
+
+[Install]
+WantedBy=timers.target
diff --git a/spreadspace/sgg-icecast.yml b/spreadspace/sgg-icecast.yml
index 7e475b72..9594da27 100644
--- a/spreadspace/sgg-icecast.yml
+++ b/spreadspace/sgg-icecast.yml
@@ -117,7 +117,7 @@
copy:
content: |
[Unit]
- Description=whawty-auth store sync timer
+ Description=Schlagergarten Stream Stats Collector
[Timer]
OnCalendar=minutely