From 41305428b225b15132a428bc4fa1af041ae198e1 Mon Sep 17 00:00:00 2001 From: Rob Date: Tue, 16 Apr 2024 20:35:54 +0000 Subject: [PATCH] add cron.nix --- modules/cron.nix | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 modules/cron.nix diff --git a/modules/cron.nix b/modules/cron.nix new file mode 100644 index 0000000..6f6fc1d --- /dev/null +++ b/modules/cron.nix @@ -0,0 +1,35 @@ +{ pkgs, ... }: + + +{ + +# name = "Backup spaceboyz web/db"; ## incl. nextcloud-data. leider ist nexcloud ordner nicht dabei +# job = "/root/lokale-scripte/rsync-nextcloud/rsync-nextcloud.sh"; + + systemd.services.spaceboyz_backup = { + serviceConfig.Type = "oneshot"; + serviceConfig.Persistent = true; ## nachholen, wenn heute noch nicht gestartet + serviceConfig.User = "root"; + path = with pkgs; [ + curl + bash + rsync + openssh + ]; + + script = '' + workDir="/root/lokale-scripte/rsync-nextcloud" + cd $workDir + echo "last run: $(date +%F) $(date +%T)" >> $workDir/last_run + echo "Start run $(date +%F) $(date +%T)" > run.log + bash rsync-nextcloud.sh >> run.log 2>&1 + echo "Finish run $(date +%F) $(date +%T)" >> run.log + ''; + }; + + systemd.timers.spaceboyz_backup = { + wantedBy = [ "timers.target" ]; + partOf = [ "spaceboyz_backup.service" ]; + timerConfig.OnCalendar = [ "*-*-* *:00:00" ]; # ist jetzt stündlich # "daily"; # [ "*-*-* *:*:00" ]; + }; +}