summaryrefslogtreecommitdiffstats
path: root/lass/3modules/mysql-backup.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2019-01-16 11:20:14 +0100
committertv <tv@krebsco.de>2019-01-16 11:20:14 +0100
commit6cef97deb3a96731a4737f05513e2e5855f60685 (patch)
treec21b0eef944b80adecb7d95aa79ba4a475ef6dd1 /lass/3modules/mysql-backup.nix
parent2d2ab95f0707209c4c248d43cb57877a50a37991 (diff)
parenta1d9c22bbd8eff9198f378e9007ddf4cb9ee2e5c (diff)
Merge remote-tracking branch 'prism/master'
Diffstat (limited to 'lass/3modules/mysql-backup.nix')
-rw-r--r--lass/3modules/mysql-backup.nix16
1 files changed, 8 insertions, 8 deletions
diff --git a/lass/3modules/mysql-backup.nix b/lass/3modules/mysql-backup.nix
index d2ae67171..516f96c34 100644
--- a/lass/3modules/mysql-backup.nix
+++ b/lass/3modules/mysql-backup.nix
@@ -41,7 +41,7 @@ let
};
location = mkOption {
type = str;
- default = "/bku/sql_dumps";
+ default = "/backups/sql_dumps";
};
};
}));
@@ -51,11 +51,9 @@ let
imp = {
- #systemd.timers =
- # mapAttrs (_: plan: {
- # wantedBy = [ "timers.target" ];
- # timerConfig = plan.timerConfig;
- #}) cfg.config;
+ services.mysql.ensureUsers = [
+ { ensurePermissions = { "*.*" = "ALL"; }; name = "root"; }
+ ];
systemd.services =
mapAttrs' (_: plan: nameValuePair "mysqlBackup-${plan.name}" {
@@ -75,8 +73,10 @@ let
start = plan: let
- backupScript = plan: db:
- "mysqldump -u ${plan.user} ${optionalString (plan.password != null) "-p$(cat ${plan.password})"} ${db} | gzip -c > ${plan.location}/${db}.gz";
+ backupScript = plan: db: ''
+ mkdir -p ${plan.location}
+ mysqldump -u ${plan.user} ${optionalString (plan.password != null) "-p$(cat ${plan.password})"} ${db} | gzip -c > ${plan.location}/${db}.gz
+ '';
in pkgs.pkgs.writeDash "mysqlBackup.${plan.name}" ''
${concatMapStringsSep "\n" (backupScript plan) plan.databases}