]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/databases/utils.nix
Add replication for redis
[perso/Immae/Config/Nix.git] / modules / private / databases / utils.nix
index c296f49d8aacee7f410f2852f7798f64c795c962..06ce2cc9e9ecca0c8e0d384d3a5a53ac54fd7d03 100644 (file)
@@ -1,15 +1,15 @@
 { pkgs }:
 {
-  keepLastNDumps = backupDir: n: ''
+  keepLastNDumps = ext: backupDir: n: ''
     #!${pkgs.stdenv.shell}
 
     cd ${backupDir}
     ${pkgs.coreutils}/bin/rm -f \
-      $(${pkgs.coreutils}/bin/ls -1 *.sql \
+      $(${pkgs.coreutils}/bin/ls -1 *.${ext} \
         | ${pkgs.coreutils}/bin/sort -r \
         | ${pkgs.gnused}/bin/sed -e '1,${builtins.toString n}d')
     '';
-  exponentialDumps = backupDir: let
+  exponentialDumps = ext: backupDir: let
     log2rotateSrc = builtins.fetchGit {
       url = "https://github.com/avian2/pylog2rotate";
       ref = "master";
@@ -24,7 +24,7 @@
     #!${pkgs.stdenv.shell}
 
     cd ${backupDir}
-    ${pkgs.coreutils}/bin/rm -f $(ls -1 *.sql | grep -v 'T22:' | sort -r | sed -e '1,12d')
-    ${pkgs.coreutils}/bin/rm -f $(ls -1 *T22*.sql | ${log2rotate} --skip 7 --fuzz 7 --delete --format='%Y-%m-%dT%H:%M:%S+00:00.sql')
+    ${pkgs.coreutils}/bin/rm -f $(ls -1 *.${ext} | grep -v 'T22:' | sort -r | sed -e '1,12d')
+    ${pkgs.coreutils}/bin/rm -f $(ls -1 *T22*.${ext} | ${log2rotate} --skip 7 --fuzz 7 --delete --format='%Y-%m-%dT%H:%M:%S+00:00.${ext}')
     '';
 }