]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/duply_backup/default.nix
Add monitoring for duply backup
[perso/Immae/Config/Nix.git] / modules / duply_backup / default.nix
index 32fa9414324bac0117492e225a3bcd8c0a1c6fd2..bce4d658332c99bbb0915859ecdca9ae8051fcae 100644 (file)
@@ -1,7 +1,7 @@
-{ lib, pkgs, myconfig, config, ... }:
+{ lib, pkgs, config, ... }:
 
 let
-  cfg = myconfig.env.backup;
+  cfg = config.myEnv.backup;
   varDir = "/var/lib/duply";
   duplyProfile = profile: prefix: ''
     GPG_PW="${cfg.password}"
@@ -82,6 +82,7 @@ in
             ''
               touch ${varDir}/${k}.log
               ${pkgs.duply}/bin/duply ${config.secrets.location}/backup/${k}/ ${action} --force >> ${varDir}/${k}.log
+              [[ $? = 0 ]] || echo -e "Error when doing backup for ${k}, see above\n---------------------------------------" >&2
             ''
           ) config.services.duplyBackup.profiles)}
         '';
@@ -92,13 +93,11 @@ in
 
     };
 
-    security.pki.certificates = let
-      cert = pkgs.fetchurl {
+    security.pki.certificateFiles = [
+      (pkgs.fetchurl {
         url = "http://downloads.e.eriomem.net/eriomemca.pem";
         sha256 = "1ixx4c6j3m26j8dp9a3dkvxc80v1nr5aqgmawwgs06bskasqkvvh";
-      };
-    in [
-      (builtins.readFile cert)
+      })
     ];
   };
 }