diff options
Diffstat (limited to 'hel.nix')
-rw-r--r-- | hel.nix | 54 |
1 files changed, 13 insertions, 41 deletions
@@ -15,6 +15,7 @@ | |||
15 | ./custom/tinc/yggdrasil.nix | 15 | ./custom/tinc/yggdrasil.nix |
16 | ./custom/uucp.nix | 16 | ./custom/uucp.nix |
17 | ./custom/btrfs-snapshots.nix | 17 | ./custom/btrfs-snapshots.nix |
18 | ./custom/borgbackup.nix | ||
18 | ]; | 19 | ]; |
19 | 20 | ||
20 | system.stateVersion = "16.09"; | 21 | system.stateVersion = "16.09"; |
@@ -524,47 +525,18 @@ | |||
524 | 525 | ||
525 | systemd.services."NetworkManager-wait-online".enable = true; | 526 | systemd.services."NetworkManager-wait-online".enable = true; |
526 | 527 | ||
527 | services.btrfs-snapshots.enable = true; | 528 | services.backup = { |
528 | 529 | snapshots = "btrfs"; | |
529 | systemd.timers."backup-odin@home-gkleen" = { | 530 | prefix = "automatic.yggdrasil.midgard.hel."; |
530 | enable = true; | 531 | targets = { |
531 | 532 | "odin" = { | |
532 | wantedBy = [ "timers.target" ]; | 533 | repo = "borg.odin:/srv/backup/borg"; |
533 | 534 | paths = [ "home-gkleen" ]; | |
534 | timerConfig = { | 535 | }; |
535 | Persistent = true; | 536 | "munin" = { |
536 | OnUnitInactiveSec = "6h"; | 537 | repo = "borg.munin:borg"; |
537 | }; | 538 | paths = [ "home-gkleen" ]; |
538 | }; | 539 | }; |
539 | systemd.services."backup-odin@" = { | ||
540 | enable = true; | ||
541 | |||
542 | bindsTo = [ "btrfs-snapshot@%i.service" "network-online.target" ]; | ||
543 | after = [ "btrfs-snapshot@%i.service" "network-online.target" ]; | ||
544 | |||
545 | path = with pkgs; [borgbackup]; | ||
546 | |||
547 | script = '' | ||
548 | borg create \ | ||
549 | --stats \ | ||
550 | --list \ | ||
551 | --filter 'AME' \ | ||
552 | --exclude-caches \ | ||
553 | --keep-exclude-tags \ | ||
554 | --patterns-from .backup \ | ||
555 | --one-file-system \ | ||
556 | --compression auto,lzma \ | ||
557 | borg.odin:/srv/backup/borg::yggdrasil.midgard.hel.$1-{utcnow} | ||
558 | ''; | ||
559 | scriptArgs = "%i"; | ||
560 | |||
561 | serviceConfig = { | ||
562 | Type = "oneshot"; | ||
563 | WorkingDirectory = "/mnt/snapshot-%i"; | ||
564 | Nice = 15; | ||
565 | IOSchedulingClass = 2; | ||
566 | IOSchedulingPriority = 7; | ||
567 | SuccessExitStatus = [1 2]; | ||
568 | }; | 540 | }; |
569 | }; | 541 | }; |
570 | } | 542 | } |