Move to restic-client-server-mysql to options
This commit is contained in:
parent
767b4eb30b
commit
1b1d3f2c1a
|
@ -40,6 +40,7 @@
|
||||||
./services/rdp
|
./services/rdp
|
||||||
./services/restic-client-desktop
|
./services/restic-client-desktop
|
||||||
./services/restic-client-server
|
./services/restic-client-server
|
||||||
|
./restic-client-server-mysql
|
||||||
./services/syslog
|
./services/syslog
|
||||||
./services/telegram-notifications
|
./services/telegram-notifications
|
||||||
./services/tlp
|
./services/tlp
|
||||||
|
|
|
@ -1,56 +1,79 @@
|
||||||
{ path
|
{ config, inputs, lib, pkgs, ... }:
|
||||||
, tag ? "home-dir"
|
let
|
||||||
, time
|
cfg = config.services.az-restic-client-server-mysql;
|
||||||
}: { config, inputs, pkgs, ... }:
|
in
|
||||||
{
|
{
|
||||||
services.az-telegram-notifications.enable = true;
|
options = {
|
||||||
|
services.az-restic-client-server-mysql = {
|
||||||
age.secrets.resticKey.file = "${inputs.self}/scrts/restic.key.age";
|
enable = lib.mkEnableOption "Enable restic backups for MariaDB.";
|
||||||
|
path = lib.mkOption {
|
||||||
systemd.timers."restic-backups" = {
|
type = lib.types.path;
|
||||||
wantedBy = [ "timers.target" ];
|
description = "The directory to backup.";
|
||||||
partOf = [ "restic-backups.service" ];
|
};
|
||||||
timerConfig = {
|
tag = lib.mkOption {
|
||||||
OnCalendar = time;
|
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.";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services."restic-backups" = {
|
config = lib.mkIf cfg.enable {
|
||||||
serviceConfig = {
|
services.az-telegram-notifications = {
|
||||||
User = "root";
|
enable = true;
|
||||||
Type = "oneshot";
|
|
||||||
};
|
};
|
||||||
environment = {
|
|
||||||
RESTIC_PASSWORD_FILE = config.age.secrets.resticKey.path;
|
age.secrets.resticKey.file = "${inputs.self}/scrts/restic.key.age";
|
||||||
RESTIC_REPOSITORY = "rest:http://10.7.89.30:8000";
|
|
||||||
|
systemd.timers."restic-backups" = {
|
||||||
|
wantedBy = [ "timers.target" ];
|
||||||
|
partOf = [ "restic-backups.service" ];
|
||||||
|
timerConfig = {
|
||||||
|
OnCalendar = cfg.time;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
onFailure = [ "unit-status-telegram@%n.service" ];
|
|
||||||
script = ''
|
|
||||||
${pkgs.restic}/bin/restic backup \
|
|
||||||
--exclude-file=${inputs.self}/modules/misc/restic-client/excludes.txt \
|
|
||||||
--tag ${tag} ${path}
|
|
||||||
|
|
||||||
${pkgs.mariadb}/bin/mariabackup --backup --user=root --stream=xbstream | \
|
systemd.services."restic-backups" = {
|
||||||
${pkgs.restic}/bin/restic backup \
|
serviceConfig = {
|
||||||
--tag mariadb \
|
User = "root";
|
||||||
--stdin \
|
Type = "oneshot";
|
||||||
--stdin-filename mariadb.xb
|
};
|
||||||
|
environment = {
|
||||||
|
RESTIC_PASSWORD_FILE = config.age.secrets.resticKey.path;
|
||||||
|
RESTIC_REPOSITORY = "rest:http://10.7.89.30:8000";
|
||||||
|
};
|
||||||
|
onFailure = [ "unit-status-telegram@%n.service" ];
|
||||||
|
script = ''
|
||||||
|
${pkgs.restic}/bin/restic backup \
|
||||||
|
--exclude-file=${inputs.self}/modules/misc/restic-client/excludes.txt \
|
||||||
|
--tag ${cfg.tag} ${cfg.path}
|
||||||
|
|
||||||
${pkgs.restic}/bin/restic forget \
|
${pkgs.mariadb}/bin/mariabackup --backup --user=root --stream=xbstream | \
|
||||||
--tag home-dir \
|
${pkgs.restic}/bin/restic backup \
|
||||||
--host ${config.networking.hostName} \
|
--tag mariadb \
|
||||||
--keep-daily 7 \
|
--stdin \
|
||||||
--keep-weekly 5 \
|
--stdin-filename mariadb.xb
|
||||||
--keep-monthly 12 \
|
|
||||||
--keep-yearly 75
|
|
||||||
|
|
||||||
${pkgs.restic}/bin/restic forget \
|
${pkgs.restic}/bin/restic forget \
|
||||||
--tag mariadb \
|
--tag home-dir \
|
||||||
--host ${config.networking.hostName} \
|
--host ${config.networking.hostName} \
|
||||||
--keep-daily 7 \
|
--keep-daily 7 \
|
||||||
--keep-weekly 5 \
|
--keep-weekly 5 \
|
||||||
--keep-monthly 12 \
|
--keep-monthly 12 \
|
||||||
--keep-yearly 75
|
--keep-yearly 75
|
||||||
'';
|
|
||||||
|
${pkgs.restic}/bin/restic forget \
|
||||||
|
--tag mariadb \
|
||||||
|
--host ${config.networking.hostName} \
|
||||||
|
--keep-daily 7 \
|
||||||
|
--keep-weekly 5 \
|
||||||
|
--keep-monthly 12 \
|
||||||
|
--keep-yearly 75
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,6 @@ in
|
||||||
ip = "10.7.89.109";
|
ip = "10.7.89.109";
|
||||||
inherit hostname;
|
inherit hostname;
|
||||||
})
|
})
|
||||||
(import "${inputs.self}/modules/restic-client-server-mysql" {
|
|
||||||
path = "/home/andreas";
|
|
||||||
time = "00:30";
|
|
||||||
})
|
|
||||||
];
|
];
|
||||||
services = {
|
services = {
|
||||||
az-gitea = {
|
az-gitea = {
|
||||||
|
@ -22,5 +18,10 @@ in
|
||||||
enable = true;
|
enable = true;
|
||||||
domain = domain;
|
domain = domain;
|
||||||
};
|
};
|
||||||
|
az-restic-client-server-mysql = {
|
||||||
|
enable = true;
|
||||||
|
path = "/home/andreas";
|
||||||
|
time = "00:30";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,6 @@
|
||||||
ip = "10.7.89.103";
|
ip = "10.7.89.103";
|
||||||
inherit hostname;
|
inherit hostname;
|
||||||
})
|
})
|
||||||
(import "${inputs.self}/modules/restic-client-server-mysql" {
|
|
||||||
path = "/home/andreas";
|
|
||||||
time = "01:30";
|
|
||||||
})
|
|
||||||
];
|
];
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
|
@ -16,5 +12,10 @@
|
||||||
enable = true;
|
enable = true;
|
||||||
domain = "nextcloud.2li.ch";
|
domain = "nextcloud.2li.ch";
|
||||||
};
|
};
|
||||||
|
az-restic-client-server-mysql = {
|
||||||
|
enable = true;
|
||||||
|
path = "/home/andreas";
|
||||||
|
time = "01:30";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue