Add notification for failed backups

This commit is contained in:
2024-06-18 15:40:17 -07:00
parent d1ad6c2679
commit 6bf2465adf

View File

@@ -1,6 +1,27 @@
{ pkgs, config, ... }:
{
environment.systemPackages = [pkgs.restic];
environment.systemPackages = with pkgs; [
restic
libnotify
];
systemd.services = {
notify-backup-b2-failed = {
description = "Notify on failed backup to B2";
serviceConfig = {
Type = "oneshot";
User = "nettika";
};
environment = {
DBUS_SESSION_BUS_ADDRESS = "unix:path=/run/user/1000/bus";
};
path = [ pkgs.libnotify ];
script = "notify-send -u critical \"Backup to B2 failed\" \"$(journalctl -u restic-backups-b2 -n 5 -o cat)\"";
};
restic-backups-b2 = {
onFailure = ["notify-backup-b2-failed.service"];
};
};
services.restic.backups = {
b2 = {