]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Backup mysql cron
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 14 Mar 2019 07:48:24 +0000 (08:48 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 14 Mar 2019 07:48:24 +0000 (08:48 +0100)
nixops/modules/databases/mysql.nix

index acf47509d573be234a135c6d881727a7716b59be..a625d48be46f44f085985f85d27ce481314c4dfd 100644 (file)
@@ -51,6 +51,21 @@ in {
       '';
     };
 
+    services.cron = {
+      enable = true;
+      systemCronJobs = let
+        mycnf = pkgs.writeText "my.cnf" ''
+          [mysqldump]
+          user = root
+          password = ${myconfig.env.databases.mysql.systemUsers.root}
+          '';
+      in [
+        ''
+          30 1,13 * * * root ${pkgs.mariadb}/bin/mysqldump --defaults-file=${mycnf} --all-databases > /var/lib/mysql/backup.sql
+        ''
+      ];
+    };
+
     security.pam.services = let
       pam_ldap = "${pkgs.pam_ldap}/lib/security/pam_ldap.so";
       pam_ldap_mysql = with myconfig.env.databases.mysql.pam;