aboutsummaryrefslogtreecommitdiff
path: root/modules/private/databases
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2020-01-02 19:27:02 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2020-01-02 19:27:02 +0100
commit4c853ba6f422460ebfb775856920542db6a88fb8 (patch)
treea9770d3656873a7ebea125aa3825426bde75bcf2 /modules/private/databases
parent36c368d041ea5abb6209f6406d8bcd4eba3462c3 (diff)
downloadNix-4c853ba6f422460ebfb775856920542db6a88fb8.tar.gz
Nix-4c853ba6f422460ebfb775856920542db6a88fb8.tar.zst
Nix-4c853ba6f422460ebfb775856920542db6a88fb8.zip
Use minute precision for backups
Diffstat (limited to 'modules/private/databases')
-rw-r--r--modules/private/databases/mariadb_replication.nix2
-rw-r--r--modules/private/databases/openldap_replication.nix2
-rw-r--r--modules/private/databases/postgresql_replication.nix2
-rw-r--r--modules/private/databases/redis_replication.nix2
-rw-r--r--modules/private/databases/utils.nix2
5 files changed, 5 insertions, 5 deletions
diff --git a/modules/private/databases/mariadb_replication.nix b/modules/private/databases/mariadb_replication.nix
index ca1432f..740bdac 100644
--- a/modules/private/databases/mariadb_replication.nix
+++ b/modules/private/databases/mariadb_replication.nix
@@ -144,7 +144,7 @@ in
144 --gtid \ 144 --gtid \
145 --master-data \ 145 --master-data \
146 --flush-privileges \ 146 --flush-privileges \
147 --all-databases > ${backupDir}/$(${pkgs.coreutils}/bin/date -Iseconds).sql 147 --all-databases > ${backupDir}/$(${pkgs.coreutils}/bin/date -Iminutes).sql
148 ''; 148 '';
149 u = pkgs.callPackage ./utils.nix {}; 149 u = pkgs.callPackage ./utils.nix {};
150 cleanup_script = pkgs.writeScript "cleanup_mysql_${name}" (u.exponentialDumps "sql" backupDir); 150 cleanup_script = pkgs.writeScript "cleanup_mysql_${name}" (u.exponentialDumps "sql" backupDir);
diff --git a/modules/private/databases/openldap_replication.nix b/modules/private/databases/openldap_replication.nix
index 7833e31..2980c97 100644
--- a/modules/private/databases/openldap_replication.nix
+++ b/modules/private/databases/openldap_replication.nix
@@ -120,7 +120,7 @@ in
120 backup_script = pkgs.writeScript "backup_openldap_${name}" '' 120 backup_script = pkgs.writeScript "backup_openldap_${name}" ''
121 #!${pkgs.stdenv.shell} 121 #!${pkgs.stdenv.shell}
122 122
123 ${hcfg.package}/bin/slapcat -b "${hcfg.base}" -f ${ldapConfig hcfg name} -l ${backupDir}/$(${pkgs.coreutils}/bin/date -Iseconds).ldif 123 ${hcfg.package}/bin/slapcat -b "${hcfg.base}" -f ${ldapConfig hcfg name} -l ${backupDir}/$(${pkgs.coreutils}/bin/date -Iminutes).ldif
124 ''; 124 '';
125 u = pkgs.callPackage ./utils.nix {}; 125 u = pkgs.callPackage ./utils.nix {};
126 cleanup_script = pkgs.writeScript "cleanup_openldap_${name}" (u.exponentialDumps "ldif" backupDir); 126 cleanup_script = pkgs.writeScript "cleanup_openldap_${name}" (u.exponentialDumps "ldif" backupDir);
diff --git a/modules/private/databases/postgresql_replication.nix b/modules/private/databases/postgresql_replication.nix
index 19ec168..7172c5e 100644
--- a/modules/private/databases/postgresql_replication.nix
+++ b/modules/private/databases/postgresql_replication.nix
@@ -113,7 +113,7 @@ in
113 113
114 ${hcfg.package}/bin/psql -h ${dataDir} -c "SELECT pg_wal_replay_pause();" >/dev/null || (echo "impossible to pause replication" && false) 114 ${hcfg.package}/bin/psql -h ${dataDir} -c "SELECT pg_wal_replay_pause();" >/dev/null || (echo "impossible to pause replication" && false)
115 115
116 ${hcfg.package}/bin/pg_dumpall -h ${dataDir} -f ${backupDir}/$(${pkgs.coreutils}/bin/date -Iseconds).sql 116 ${hcfg.package}/bin/pg_dumpall -h ${dataDir} -f ${backupDir}/$(${pkgs.coreutils}/bin/date -Iminutes).sql
117 ''; 117 '';
118 u = pkgs.callPackage ./utils.nix {}; 118 u = pkgs.callPackage ./utils.nix {};
119 cleanup_script = pkgs.writeScript "cleanup_postgresql_${name}" (u.keepLastNDumps "sql" backupDir 12); 119 cleanup_script = pkgs.writeScript "cleanup_postgresql_${name}" (u.keepLastNDumps "sql" backupDir 12);
diff --git a/modules/private/databases/redis_replication.nix b/modules/private/databases/redis_replication.nix
index 6ec52c9..a3fe3bb 100644
--- a/modules/private/databases/redis_replication.nix
+++ b/modules/private/databases/redis_replication.nix
@@ -117,7 +117,7 @@ in
117 #!${pkgs.stdenv.shell} 117 #!${pkgs.stdenv.shell}
118 118
119 ${pkgs.coreutils}/bin/cp ${cfg.base}/${name}/redis/dump.rdb \ 119 ${pkgs.coreutils}/bin/cp ${cfg.base}/${name}/redis/dump.rdb \
120 ${backupDir}/$(${pkgs.coreutils}/bin/date -Iseconds).rdb 120 ${backupDir}/$(${pkgs.coreutils}/bin/date -Iminutes).rdb
121 ''; 121 '';
122 u = pkgs.callPackage ./utils.nix {}; 122 u = pkgs.callPackage ./utils.nix {};
123 cleanup_script = pkgs.writeScript "cleanup_redis_${name}" (u.exponentialDumps "rdb" backupDir); 123 cleanup_script = pkgs.writeScript "cleanup_redis_${name}" (u.exponentialDumps "rdb" backupDir);
diff --git a/modules/private/databases/utils.nix b/modules/private/databases/utils.nix
index 06ce2cc..47988fc 100644
--- a/modules/private/databases/utils.nix
+++ b/modules/private/databases/utils.nix
@@ -25,6 +25,6 @@
25 25
26 cd ${backupDir} 26 cd ${backupDir}
27 ${pkgs.coreutils}/bin/rm -f $(ls -1 *.${ext} | grep -v 'T22:' | sort -r | sed -e '1,12d') 27 ${pkgs.coreutils}/bin/rm -f $(ls -1 *.${ext} | grep -v 'T22:' | sort -r | sed -e '1,12d')
28 ${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}') 28 ${pkgs.coreutils}/bin/rm -f $(ls -1 *T22*.${ext} | ${log2rotate} --skip 7 --fuzz 7 --delete --format='%Y-%m-%dT%H:%M+00:00.${ext}')
29 ''; 29 '';
30} 30}