summaryrefslogtreecommitdiffstats
path: root/lass/3modules/mysql-backup.nix
diff options
context:
space:
mode:
authorlassulus <git@lassul.us>2023-09-07 12:26:31 +0200
committerlassulus <git@lassul.us>2023-09-07 13:50:26 +0200
commitf55307fd73af235069744dd5155fda0bc73fe613 (patch)
treef048d7750a50e48493505a08784c96d07d291f89 /lass/3modules/mysql-backup.nix
parent85ae348bf3f53125c8281669a32bf007dc0063be (diff)
lass: migrate away
Diffstat (limited to 'lass/3modules/mysql-backup.nix')
-rw-r--r--lass/3modules/mysql-backup.nix86
1 files changed, 0 insertions, 86 deletions
diff --git a/lass/3modules/mysql-backup.nix b/lass/3modules/mysql-backup.nix
deleted file mode 100644
index 516f96c3..00000000
--- a/lass/3modules/mysql-backup.nix
+++ /dev/null
@@ -1,86 +0,0 @@
-{ config, lib, pkgs, ... }:
-
-with lib;
-
-let
-
- cfg = config.lass.mysqlBackup;
-
- out = {
- options.lass.mysqlBackup = api;
- config = mkIf cfg.enable imp;
- };
-
- api = {
- enable = mkEnableOption "mysqlBackup";
- config = mkOption {
- type = with types; attrsOf (submodule ({ config, ... }: {
- options = {
- name = mkOption {
- type = types.str;
- default = config._module.args.name;
- };
- startAt = mkOption {
- type = with types; nullOr str; # TODO systemd.time(7)'s calendar event
- default = "*-*-* 01:15:00";
- };
- user = mkOption {
- type = str;
- default = "root";
- };
- password = mkOption {
- type = nullOr str;
- default = null;
- description = ''
- path to a file containing the mysqlPassword for the specified user.
- '';
- };
- databases = mkOption {
- type = listOf str;
- default = [];
- };
- location = mkOption {
- type = str;
- default = "/backups/sql_dumps";
- };
- };
- }));
- description = "configuration for mysqlBackup";
- };
- };
-
- imp = {
-
- services.mysql.ensureUsers = [
- { ensurePermissions = { "*.*" = "ALL"; }; name = "root"; }
- ];
-
- systemd.services =
- mapAttrs' (_: plan: nameValuePair "mysqlBackup-${plan.name}" {
- path = with pkgs; [
- mysql
- gzip
- ];
- serviceConfig = rec {
- ExecStart = start plan;
- SyslogIdentifier = ExecStart.name;
- Type = "oneshot";
- User = plan.user;
- };
- startAt = plan.startAt;
- }) cfg.config;
- };
-
-
- start = plan: let
- 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}
- '';
-
-
-in out