Move to restic-client-server-mysql to options

This commit is contained in:
Andreas Zweili 2023-06-06 22:19:23 +02:00
parent 767b4eb30b
commit 1b1d3f2c1a
4 changed files with 79 additions and 53 deletions

View File

@ -40,6 +40,7 @@
./services/rdp
./services/restic-client-desktop
./services/restic-client-server
./restic-client-server-mysql
./services/syslog
./services/telegram-notifications
./services/tlp

View File

@ -1,9 +1,31 @@
{ path
, tag ? "home-dir"
, time
}: { config, inputs, pkgs, ... }:
{ config, inputs, lib, pkgs, ... }:
let
cfg = config.services.az-restic-client-server-mysql;
in
{
services.az-telegram-notifications.enable = true;
options = {
services.az-restic-client-server-mysql = {
enable = lib.mkEnableOption "Enable restic backups for MariaDB.";
path = lib.mkOption {
type = lib.types.path;
description = "The directory to backup.";
};
tag = lib.mkOption {
type = lib.types.str;
description = "The tag to attach to the backups.";
default = "home-dir";
};
time = lib.mkOption {
type = lib.types.str;
description = "The time at which the backup runs.";
};
};
};
config = lib.mkIf cfg.enable {
services.az-telegram-notifications = {
enable = true;
};
age.secrets.resticKey.file = "${inputs.self}/scrts/restic.key.age";
@ -11,7 +33,7 @@
wantedBy = [ "timers.target" ];
partOf = [ "restic-backups.service" ];
timerConfig = {
OnCalendar = time;
OnCalendar = cfg.time;
};
};
@ -28,7 +50,7 @@
script = ''
${pkgs.restic}/bin/restic backup \
--exclude-file=${inputs.self}/modules/misc/restic-client/excludes.txt \
--tag ${tag} ${path}
--tag ${cfg.tag} ${cfg.path}
${pkgs.mariadb}/bin/mariabackup --backup --user=root --stream=xbstream | \
${pkgs.restic}/bin/restic backup \
@ -53,4 +75,5 @@
--keep-yearly 75
'';
};
};
}

View File

@ -8,10 +8,6 @@ in
ip = "10.7.89.109";
inherit hostname;
})
(import "${inputs.self}/modules/restic-client-server-mysql" {
path = "/home/andreas";
time = "00:30";
})
];
services = {
az-gitea = {
@ -22,5 +18,10 @@ in
enable = true;
domain = domain;
};
az-restic-client-server-mysql = {
enable = true;
path = "/home/andreas";
time = "00:30";
};
};
}

View File

@ -5,10 +5,6 @@
ip = "10.7.89.103";
inherit hostname;
})
(import "${inputs.self}/modules/restic-client-server-mysql" {
path = "/home/andreas";
time = "01:30";
})
];
services = {
@ -16,5 +12,10 @@
enable = true;
domain = "nextcloud.2li.ch";
};
az-restic-client-server-mysql = {
enable = true;
path = "/home/andreas";
time = "01:30";
};
};
}