l sqlBackup: fix permissions/folders
This commit is contained in:
parent
a46b647505
commit
81de4a0473
@ -20,9 +20,7 @@
|
|||||||
|
|
||||||
lass.mysqlBackup = {
|
lass.mysqlBackup = {
|
||||||
enable = true;
|
enable = true;
|
||||||
config.all = {
|
config.all = {};
|
||||||
password = toString (<secrets/mysql_rootPassword>);
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ let
|
|||||||
};
|
};
|
||||||
location = mkOption {
|
location = mkOption {
|
||||||
type = str;
|
type = str;
|
||||||
default = "/bku/sql_dumps";
|
default = "/backups/sql_dumps";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}));
|
}));
|
||||||
@ -51,11 +51,9 @@ let
|
|||||||
|
|
||||||
imp = {
|
imp = {
|
||||||
|
|
||||||
#systemd.timers =
|
services.mysql.ensureUsers = [
|
||||||
# mapAttrs (_: plan: {
|
{ ensurePermissions = { "*.*" = "ALL"; }; name = "root"; }
|
||||||
# wantedBy = [ "timers.target" ];
|
];
|
||||||
# timerConfig = plan.timerConfig;
|
|
||||||
#}) cfg.config;
|
|
||||||
|
|
||||||
systemd.services =
|
systemd.services =
|
||||||
mapAttrs' (_: plan: nameValuePair "mysqlBackup-${plan.name}" {
|
mapAttrs' (_: plan: nameValuePair "mysqlBackup-${plan.name}" {
|
||||||
@ -75,8 +73,10 @@ let
|
|||||||
|
|
||||||
|
|
||||||
start = plan: let
|
start = plan: let
|
||||||
backupScript = plan: db:
|
backupScript = plan: db: ''
|
||||||
"mysqldump -u ${plan.user} ${optionalString (plan.password != null) "-p$(cat ${plan.password})"} ${db} | gzip -c > ${plan.location}/${db}.gz";
|
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}" ''
|
in pkgs.pkgs.writeDash "mysqlBackup.${plan.name}" ''
|
||||||
${concatMapStringsSep "\n" (backupScript plan) plan.databases}
|
${concatMapStringsSep "\n" (backupScript plan) plan.databases}
|
||||||
|
Loading…
Reference in New Issue
Block a user