mirror of
https://github.com/Ahwxorg/nixos-config.git
synced 2025-12-04 15:00:13 +01:00
feat: adds bare borg-backup service for violet
This commit is contained in:
parent
80094a6827
commit
1b514a44c2
1 changed files with 54 additions and 0 deletions
54
hosts/violet/backups.nix
Normal file
54
hosts/violet/backups.nix
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
let
|
||||||
|
borgbackupMonitor =
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib;
|
||||||
|
{
|
||||||
|
key = "borgbackupMonitor";
|
||||||
|
_file = "borgbackupMonitor";
|
||||||
|
config.systemd.services =
|
||||||
|
{
|
||||||
|
"notify-problems@" = {
|
||||||
|
enable = true;
|
||||||
|
serviceConfig.User = "liv";
|
||||||
|
environment.SERVICE = "%i";
|
||||||
|
script = ''
|
||||||
|
${pkgs.curl}/bin/curl -d "$SERVICE FAILED! - service $SERVICE on host $(hostname) failed, run journalctl -u $SERVICE for details."
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// flip mapAttrs' config.services.borgbackup.jobs (
|
||||||
|
name: value:
|
||||||
|
nameValuePair "borgbackup-job-${name}" {
|
||||||
|
unitConfig.OnFailure = "notify-problems@%i.service";
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
# optional, but this actually forces backup after boot in case laptop was powered off during scheduled event
|
||||||
|
# for example, if you scheduled backups daily, your laptop should be powered on at 00:00
|
||||||
|
config.systemd.timers = flip mapAttrs' config.services.borgbackup.jobs (
|
||||||
|
name: value:
|
||||||
|
nameValuePair "borgbackup-job-${name}" {
|
||||||
|
timerConfig.Persistent = true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
{
|
||||||
|
imports = [ borgbackupMonitor ];
|
||||||
|
services = {
|
||||||
|
borgbackup.jobs.liv-violet = {
|
||||||
|
paths = "/home/liv";
|
||||||
|
encryption.mode = "none";
|
||||||
|
environment.BORG_RSH = "ssh -i /home/liv/.ssh/id_ed25519";
|
||||||
|
repo = "ssh://liv@100.115.178.50:9123/spinners/rootvol/backups/hosts/violet";
|
||||||
|
compression = "auto,zstd";
|
||||||
|
startAt = "daily";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue