mirror of
https://github.com/Ahwxorg/nixos-config.git
synced 2025-12-04 06:50:14 +01:00
feat: adds borgbackup job for grafana
This commit is contained in:
parent
1e32339273
commit
c09d9a5e9d
1 changed files with 35 additions and 1 deletions
|
|
@ -1,4 +1,13 @@
|
|||
{ config, ... }:
|
||||
{
|
||||
config,
|
||||
host,
|
||||
username,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
baseRepo = "ssh://liv@dandelion:9123/spinners/rootvol/backups/${host}";
|
||||
in
|
||||
{
|
||||
services = {
|
||||
grafana = {
|
||||
|
|
@ -19,5 +28,30 @@
|
|||
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";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue