all repos — nixfiles @ a7a6e3c01f8a14f23a78ad4fd3578b7fab7c0db1

System and user configuration, managed by nix and home-manager

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))
Alan Pearce alan@alanpearce.eu
Sun, 05 Jan 2025 12:05:55 +0100
commit

a7a6e3c01f8a14f23a78ad4fd3578b7fab7c0db1

parent

c95680fd90d59c71a5eacc64345dc877d2f4ab79

1 files changed, 10 insertions(+), 13 deletions(-)

jump to
M system/linde.nixsystem/linde.nix
@@ -455,31 +455,28 @@   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";
     };
   };