]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/databases/postgresql_replication.nix
Add mysql replication
[perso/Immae/Config/Nix.git] / modules / private / databases / postgresql_replication.nix
index 145fcac7510c690ceb4e82b6487afd970a198d1f..cc32c2be448ccad28ec97c872baa1b05c8a968e1 100644 (file)
@@ -115,9 +115,11 @@ in
 
               ${hcfg.package}/bin/pg_dumpall -h ${dataDir} -f ${backupDir}/$(${pkgs.coreutils}/bin/date -Iseconds).sql
             '';
+          u = pkgs.callPackage ./utils.nix {};
+          cleanup_script = pkgs.writeScript "cleanup_postgresql_${name}" (u.keepLastNDumps backupDir 12);
         in [
           "0 22,4,10,16 * * * postgres ${backup_script}"
-          "0 3 * * * postgres ${pkgs.coreutils}/bin/rm -f $(${pkgs.coreutils}/bin/ls -1 ${backupDir}/*.sql | ${pkgs.coreutils}/bin/sort -r | ${pkgs.gnused}/bin/sed -e '1,12d')"
+          "0 3 * * * postgres ${cleanup_script}"
         ]) cfg.hosts);
     };