summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2025-01-05 12:05:55 +0100
committerAlan Pearce2025-01-05 12:05:55 +0100
commita7a6e3c01f8a14f23a78ad4fd3578b7fab7c0db1 (patch)
treec8230f98225b7565694a58c172bb286ae7c4640f
parentc95680fd90d59c71a5eacc64345dc877d2f4ab79 (diff)
downloadnixfiles-a7a6e3c01f8a14f23a78ad4fd3578b7fab7c0db1.tar.lz
nixfiles-a7a6e3c01f8a14f23a78ad4fd3578b7fab7c0db1.tar.zst
nixfiles-a7a6e3c01f8a14f23a78ad4fd3578b7fab7c0db1.zip
linde: fix rdiff-backup error handling
the `remove increments` subcommand often emits warnings and returns a
non-zero error code, which is ignored by the `-` prefix of the
command (see systemd.service(5))
-rw-r--r--system/linde.nix23
1 files changed, 10 insertions, 13 deletions
diff --git a/system/linde.nix b/system/linde.nix
index b18015bb..29260c21 100644
--- a/system/linde.nix
+++ b/system/linde.nix
@@ -455,31 +455,28 @@ in
   systemd.services.backup-gitolite = {
     startAt = "daily";
     path = with pkgs; [
-      rdiff-backup
       openssh
     ];
-    script = ''
-      rdiff-backup --api-version 201 backup ${config.services.gitolite.dataDir} ${hostname}@nano.${ts-domain}::gitolite
-      rdiff-backup --api-version 201 remove increments --older-than 3M ${hostname}@nano.${ts-domain}::gitolite
-    '';
-    serviceConfig.Type = "oneshot";
+    serviceConfig = {
+      Type = "oneshot";
+      ExecStart = "${lib.getExe pkgs.rdiff-backup} --api-version 201 backup ${config.services.gitolite.dataDir} ${hostname}@nano.${ts-domain}::gitolite";
+      ExecStartPost = "-${lib.getExe pkgs.rdiff-backup} --api-version 201 remove increments --older-than 3M ${hostname}@nano.${ts-domain}::gitolite";
+    };
   };
 
   systemd.services.backup-paperless = {
     startAt = "daily";
     path = with pkgs; [
-      sudo
-      rdiff-backup
       openssh
     ];
-    script = ''
-      systemd-run --machine=papers sudo -u paperless ./paperless-manage document_exporter --delete --use-filename-format --no-archive --no-thumbnail --no-progress-bar ./export
-      rdiff-backup --api-version 201 backup /srv/paperless/export ${hostname}@nano.${ts-domain}::paperless
-      rdiff-backup --api-version 201 remove increments --older-than 3M ${hostname}@nano.${ts-domain}::paperless
-    '';
     serviceConfig = {
       Type = "oneshot";
       WorkingDirectory = config.services.paperless.dataDir;
+      ExecStart = [
+        "systemd-run --machine=papers sudo -u paperless ./paperless-manage document_exporter --delete --use-filename-format --no-archive --no-thumbnail --no-progress-bar ./export  "
+        "${lib.getExe pkgs.rdiff-backup} --api-version 201 backup /srv/paperless/export ${hostname}@nano.${ts-domain}::paperless"
+      ];
+      ExecStartPost = "-${lib.getExe pkgs.rdiff-backup} --api-version 201 remove increments --older-than 3M ${hostname}@nano.${ts-domain}::paperless";
     };
   };