From 458d48291fd1e18212b9911718f75edd053ac1c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Sch=C3=A4ferdiek?= Date: Sun, 12 Jun 2022 12:28:01 +0200 Subject: [PATCH] Also provide restic scripts as systemd global service --- etc/pacman.d/hooks/100-systemd-boot.hook | 9 +++++++++ ...mirrorupgrade.hook => 200-mirrorupgrade.hook} | 0 etc/systemd/system/restic-check@.service | 16 ++++++++++++++++ etc/systemd/system/restic-check@.timer | 9 +++++++++ etc/systemd/system/restic-create@.service | 16 ++++++++++++++++ etc/systemd/system/restic-create@.timer | 9 +++++++++ etc/systemd/system/restic-prune@.service | 16 ++++++++++++++++ etc/systemd/system/restic-prune@.timer | 9 +++++++++ 8 files changed, 84 insertions(+) create mode 100644 etc/pacman.d/hooks/100-systemd-boot.hook rename etc/pacman.d/hooks/{mirrorupgrade.hook => 200-mirrorupgrade.hook} (100%) create mode 100644 etc/systemd/system/restic-check@.service create mode 100644 etc/systemd/system/restic-check@.timer create mode 100644 etc/systemd/system/restic-create@.service create mode 100644 etc/systemd/system/restic-create@.timer create mode 100644 etc/systemd/system/restic-prune@.service create mode 100644 etc/systemd/system/restic-prune@.timer diff --git a/etc/pacman.d/hooks/100-systemd-boot.hook b/etc/pacman.d/hooks/100-systemd-boot.hook new file mode 100644 index 0000000..d65c027 --- /dev/null +++ b/etc/pacman.d/hooks/100-systemd-boot.hook @@ -0,0 +1,9 @@ +[Trigger] +Type = Package +Operation = Upgrade +Target = systemd + +[Action] +Description = Gracefully upgrading systemd-boot... +When = PostTransaction +Exec = /usr/bin/systemctl restart systemd-boot-update.service diff --git a/etc/pacman.d/hooks/mirrorupgrade.hook b/etc/pacman.d/hooks/200-mirrorupgrade.hook similarity index 100% rename from etc/pacman.d/hooks/mirrorupgrade.hook rename to etc/pacman.d/hooks/200-mirrorupgrade.hook diff --git a/etc/systemd/system/restic-check@.service b/etc/systemd/system/restic-check@.service new file mode 100644 index 0000000..2b92d33 --- /dev/null +++ b/etc/systemd/system/restic-check@.service @@ -0,0 +1,16 @@ +[Unit] +Description=Run restic check script for %I utilizing ~/.config/restic/%I-check.sh file using env ~/.config/restic/%I.env +OnFailure=systemd_failure_notify@%n.service +Wants=network-online.target +After=network-online.target +Requires=network-online.target + +[Service] +Type=oneshot +ExecStart=sh %h/.config/restic/%I-check.sh +Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin" +Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh" +EnvironmentFile=%h/.config/restic/%I.env + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/etc/systemd/system/restic-check@.timer b/etc/systemd/system/restic-check@.timer new file mode 100644 index 0000000..2d579d0 --- /dev/null +++ b/etc/systemd/system/restic-check@.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Run restic check script for %I utilizing HOME/.config/restic/%I-check.sh file + +[Timer] +OnCalendar=Wed 22:00:00 +Persistent=false + +[Install] +WantedBy=timers.target diff --git a/etc/systemd/system/restic-create@.service b/etc/systemd/system/restic-create@.service new file mode 100644 index 0000000..c5f7b21 --- /dev/null +++ b/etc/systemd/system/restic-create@.service @@ -0,0 +1,16 @@ +[Unit] +Description=Run restic create script for %I utilizing ~/.config/restic/%I-create.sh file using env ~/.config/restic/%I.env +OnFailure=systemd_failure_notify@%n.service +Wants=network-online.target +After=network-online.target +Requires=network-online.target + +[Service] +Type=oneshot +ExecStart=sh %h/.config/restic/%I-create.sh +Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin" +Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh" +EnvironmentFile=%h/.config/restic/%I.env + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/etc/systemd/system/restic-create@.timer b/etc/systemd/system/restic-create@.timer new file mode 100644 index 0000000..526bda4 --- /dev/null +++ b/etc/systemd/system/restic-create@.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Run restic create script for %I utilizing HOME/.config/restic/%I-create.sh file + +[Timer] +OnCalendar=23:00 +Persistent=false + +[Install] +WantedBy=timers.target diff --git a/etc/systemd/system/restic-prune@.service b/etc/systemd/system/restic-prune@.service new file mode 100644 index 0000000..2b92d33 --- /dev/null +++ b/etc/systemd/system/restic-prune@.service @@ -0,0 +1,16 @@ +[Unit] +Description=Run restic check script for %I utilizing ~/.config/restic/%I-check.sh file using env ~/.config/restic/%I.env +OnFailure=systemd_failure_notify@%n.service +Wants=network-online.target +After=network-online.target +Requires=network-online.target + +[Service] +Type=oneshot +ExecStart=sh %h/.config/restic/%I-check.sh +Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin" +Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh" +EnvironmentFile=%h/.config/restic/%I.env + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/etc/systemd/system/restic-prune@.timer b/etc/systemd/system/restic-prune@.timer new file mode 100644 index 0000000..d11d5d9 --- /dev/null +++ b/etc/systemd/system/restic-prune@.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Run restic prune script for %I utilizing HOME/.config/restic/%I-prune.sh file + +[Timer] +OnCalendar=Wed 23:00:00 +Persistent=false + +[Install] +WantedBy=timers.target