From 4c853ba6f422460ebfb775856920542db6a88fb8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Thu, 2 Jan 2020 19:27:02 +0100 Subject: [PATCH] Use minute precision for backups --- modules/private/databases/mariadb_replication.nix | 2 +- modules/private/databases/openldap_replication.nix | 2 +- modules/private/databases/postgresql_replication.nix | 2 +- modules/private/databases/redis_replication.nix | 2 +- modules/private/databases/utils.nix | 2 +- 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 --gtid \ --master-data \ --flush-privileges \ - --all-databases > ${backupDir}/$(${pkgs.coreutils}/bin/date -Iseconds).sql + --all-databases > ${backupDir}/$(${pkgs.coreutils}/bin/date -Iminutes).sql ''; u = pkgs.callPackage ./utils.nix {}; 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 backup_script = pkgs.writeScript "backup_openldap_${name}" '' #!${pkgs.stdenv.shell} - ${hcfg.package}/bin/slapcat -b "${hcfg.base}" -f ${ldapConfig hcfg name} -l ${backupDir}/$(${pkgs.coreutils}/bin/date -Iseconds).ldif + ${hcfg.package}/bin/slapcat -b "${hcfg.base}" -f ${ldapConfig hcfg name} -l ${backupDir}/$(${pkgs.coreutils}/bin/date -Iminutes).ldif ''; u = pkgs.callPackage ./utils.nix {}; 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 ${hcfg.package}/bin/psql -h ${dataDir} -c "SELECT pg_wal_replay_pause();" >/dev/null || (echo "impossible to pause replication" && false) - ${hcfg.package}/bin/pg_dumpall -h ${dataDir} -f ${backupDir}/$(${pkgs.coreutils}/bin/date -Iseconds).sql + ${hcfg.package}/bin/pg_dumpall -h ${dataDir} -f ${backupDir}/$(${pkgs.coreutils}/bin/date -Iminutes).sql ''; u = pkgs.callPackage ./utils.nix {}; 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 #!${pkgs.stdenv.shell} ${pkgs.coreutils}/bin/cp ${cfg.base}/${name}/redis/dump.rdb \ - ${backupDir}/$(${pkgs.coreutils}/bin/date -Iseconds).rdb + ${backupDir}/$(${pkgs.coreutils}/bin/date -Iminutes).rdb ''; u = pkgs.callPackage ./utils.nix {}; 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 @@ cd ${backupDir} ${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}') + ${pkgs.coreutils}/bin/rm -f $(ls -1 *T22*.${ext} | ${log2rotate} --skip 7 --fuzz 7 --delete --format='%Y-%m-%dT%H:%M+00:00.${ext}') ''; } -- 2.41.0