浏览代码

chore: add cron and systemd examples

Emmanuel Bouthenot 7 月之前
父节点
当前提交
0cf5254eba

+ 15 - 0
services/cron/autopostgresqlbackup

@@ -0,0 +1,15 @@
+#!/bin/sh
+#
+# autopostgresqlbackup daily cron task
+#
+
+if [ -d /run/systemd/system ]; then
+    # Skip in favour of systemd timer.
+    exit 0
+fi
+
+if [ -x /usr/sbin/autopostgresqlbackup ]; then
+	/usr/sbin/autopostgresqlbackup
+fi
+
+exit 0

+ 11 - 0
services/systemd/autopostgresqlbackup.service

@@ -0,0 +1,11 @@
+[Unit]
+Description=autopostgresqlbackup daily service
+Documentation=man:autopostgresqlbackup(8)
+After=postgresql.target mysql.target
+
+[Service]
+Type=oneshot
+ExecStart=/usr/sbin/autopostgresqlbackup
+ProtectHome=true
+ProtectSystem=full
+PrivateTmp=true

+ 9 - 0
services/systemd/autopostgresqlbackup.timer

@@ -0,0 +1,9 @@
+[Unit]
+Description=autopostgresqlbackup daily timer
+
+[Timer]
+OnCalendar=daily
+Persistent=true
+
+[Install]
+WantedBy=timers.target