aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Grote2023-08-02 20:48:47 +0200
committerMichael Grote2023-08-02 20:48:47 +0200
commita8ef935a22643a870ecb304f8e6785bd42d768b4 (patch)
treed6cb4ef5eab88957be8c8afb7eb82a457fceea5e
parent5f543bb8f98524d64d063dfa68eb29a2531d7bba (diff)
add service units
-rw-r--r--.drone.yml3
-rw-r--r--sanoid-prune.service14
-rw-r--r--sanoid.service13
-rw-r--r--sanoid.timer9
4 files changed, 39 insertions, 0 deletions
diff --git a/.drone.yml b/.drone.yml
index d409081..1fff40b 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -41,6 +41,9 @@ steps:
--depends mbuffer \
--depends build-essential \
--depends git \
+ sanoid-prune.service=/lib/systemd/system/sanoid-prune.service \
+ sanoid.service=/lib/systemd/system/sanoid.service \
+ sanoid.timer=/lib/systemd/system/sanoid.timer \
sanoid=/usr/bin/sanoid \
syncoid=/usr/bin/syncoid \
sanoid.conf=/etc/sanoid/sanoid.conf \
diff --git a/sanoid-prune.service b/sanoid-prune.service
new file mode 100644
index 0000000..03a27f6
--- /dev/null
+++ b/sanoid-prune.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Prune ZFS snapshots
+Documentation=man:sanoid(8)
+Requires=local-fs.target
+After=local-fs.target sanoid.service
+ConditionFileNotEmpty=/etc/sanoid/sanoid.conf
+
+[Service]
+Type=oneshot
+Environment=TZ=UTC
+ExecStart=/usr/sbin/sanoid --prune-snapshots --verbose
+
+[Install]
+WantedBy=sanoid.service
diff --git a/sanoid.service b/sanoid.service
new file mode 100644
index 0000000..300a110
--- /dev/null
+++ b/sanoid.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Snapshot ZFS filesystems
+Documentation=man:sanoid(8)
+Requires=local-fs.target
+After=local-fs.target
+Before=sanoid-prune.service
+Wants=sanoid-prune.service
+ConditionFileNotEmpty=/etc/sanoid/sanoid.conf
+
+[Service]
+Type=oneshot
+Environment=TZ=UTC
+ExecStart=/usr/sbin/sanoid --take-snapshots --verbose
diff --git a/sanoid.timer b/sanoid.timer
new file mode 100644
index 0000000..3058430
--- /dev/null
+++ b/sanoid.timer
@@ -0,0 +1,9 @@
+[Unit]
+Description=Run Sanoid Every 15 Minutes
+
+[Timer]
+OnCalendar=*:0/15
+Persistent=true
+
+[Install]
+WantedBy=timers.target