diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2020-07-15 16:54:34 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2020-07-15 16:54:34 +0200 |
commit | 5868f9c64f0a2e9c03f6abee35ed0f0f09d30fe4 (patch) | |
tree | 166b717ca4287ca24d750b4f792948d9a71234e0 /modules | |
parent | c31ca68c24d6cc34624b925d69191488d3d60d44 (diff) | |
download | Nix-5868f9c64f0a2e9c03f6abee35ed0f0f09d30fe4.tar.gz Nix-5868f9c64f0a2e9c03f6abee35ed0f0f09d30fe4.tar.zst Nix-5868f9c64f0a2e9c03f6abee35ed0f0f09d30fe4.zip |
Compress sql dumps
Diffstat (limited to 'modules')
-rw-r--r-- | modules/private/databases/mariadb_replication.nix | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/modules/private/databases/mariadb_replication.nix b/modules/private/databases/mariadb_replication.nix index 740bdac..ae54265 100644 --- a/modules/private/databases/mariadb_replication.nix +++ b/modules/private/databases/mariadb_replication.nix | |||
@@ -138,16 +138,18 @@ in | |||
138 | 138 | ||
139 | set -euo pipefail | 139 | set -euo pipefail |
140 | 140 | ||
141 | filename=${backupDir}/$(${pkgs.coreutils}/bin/date -Iminutes).sql | ||
141 | ${hcfg.package}/bin/mysqldump \ | 142 | ${hcfg.package}/bin/mysqldump \ |
142 | --defaults-file=${config.secrets.location}/mysql_replication/${name}/mysqldump \ | 143 | --defaults-file=${config.secrets.location}/mysql_replication/${name}/mysqldump \ |
143 | -S /run/mysqld_${name}/mysqld.sock \ | 144 | -S /run/mysqld_${name}/mysqld.sock \ |
144 | --gtid \ | 145 | --gtid \ |
145 | --master-data \ | 146 | --master-data \ |
146 | --flush-privileges \ | 147 | --flush-privileges \ |
147 | --all-databases > ${backupDir}/$(${pkgs.coreutils}/bin/date -Iminutes).sql | 148 | --all-databases > $filename |
149 | ${pkgs.gzip}/bin/gzip $filename | ||
148 | ''; | 150 | ''; |
149 | u = pkgs.callPackage ./utils.nix {}; | 151 | u = pkgs.callPackage ./utils.nix {}; |
150 | cleanup_script = pkgs.writeScript "cleanup_mysql_${name}" (u.exponentialDumps "sql" backupDir); | 152 | cleanup_script = pkgs.writeScript "cleanup_mysql_${name}" (u.exponentialDumps "sql.gz" backupDir); |
151 | in [ | 153 | in [ |
152 | "0 22,4,10,16 * * * root ${backup_script}" | 154 | "0 22,4,10,16 * * * root ${backup_script}" |
153 | "0 3 * * * root ${cleanup_script}" | 155 | "0 3 * * * root ${cleanup_script}" |