Add notification for failed backups
This commit is contained in:
23
backup.nix
23
backup.nix
@@ -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 = {
|
||||
|
Reference in New Issue
Block a user