feat: adds borgbackup job for grafana

This commit is contained in:
Ahwx 2025-10-07 13:04:21 +02:00
parent 1e32339273
commit c09d9a5e9d

View file

@ -1,4 +1,13 @@
{ config, ... }: {
config,
host,
username,
pkgs,
...
}:
let
baseRepo = "ssh://liv@dandelion:9123/spinners/rootvol/backups/${host}";
in
{ {
services = { services = {
grafana = { grafana = {
@ -19,5 +28,30 @@
proxyWebsockets = true; proxyWebsockets = true;
}; };
}; };
borgbackup.jobs."violet-grafana" = {
paths = [ "/var/lib/grafana" ];
repo = "${baseRepo}/var-grafana";
encryption.mode = "none";
compression = "auto,zstd";
startAt = "daily";
preHook = ''
systemctl stop grafana
'';
postHook = ''
systemctl start grafana
if [ $exitStatus -eq 2 ]; then
${pkgs.ntfy-sh}/bin/ntfy send https://notify.liv.town/${host} "borgbackup: ${host} backup (grafana) failed with errors"
else
${pkgs.ntfy-sh}/bin/ntfy send https://notify.liv.town/${host} "borgbackup: ${host} backup (grafana) completed succesfully with exit status $exitStatus"
fi
'';
user = "root";
extraCreateArgs = [
"--stats"
];
environment = {
BORG_RSH = "ssh -p 9123 -i /home/${username}/.ssh/id_ed25519";
};
};
}; };
} }