-
Notifications
You must be signed in to change notification settings - Fork 1
/
doyha-backups.nix
67 lines (60 loc) · 2.21 KB
/
doyha-backups.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{ config, lib, pkgs, ... }:
let two-days = 60 * 60 * 24 * 2 - 60;
periodimail = import ./scripts/periodimail.nix { inherit pkgs; hostname = config.host.name; };
utils = import ./utils.nix;
in
{
config = lib.mkIf config.host.doyha-backups.enable {
systemd.services.backup-deretheni = {
description = "Backup deretheni";
path = with pkgs; [ borgbackup bup rsync openssh exim parallel ];
wants = [ "network-online.target" ];
serviceConfig = {
User = "edanaher";
Group = "users";
ExecStart = periodimail.wrap { interval = two-days; script = "/mnt/bak/deretheni/do.sh"; service = "backup-deretheni"; };
Restart = "on-failure";
RestartSec = "1h";
};
};
systemd.timers.backup-deretheni = utils.simple-timer "daily" "Backup deretheni daily";
services.zfs.autoSnapshot = {
enable = true;
flags = "-k -p --utc";
frequent = 2*24*4;
hourly = 14*24;
daily = 90;
weekly = 26;
monthly = 1200;
};
# systemd.services.snapshot-doyha-edanaher = {
# description = "Snapshot doyha homedir";
# path = with pkgs; [ btrfs-progs ];
# wants = [ "network-online.target" ];
# serviceConfig = {
# User = "root";
# ExecStart = periodimail.wrap { interval = two-days; script = "/home/edanaher/bin/bin/do_snapshot_home"; service = "snapshot-doyha-edanaher"; };
# };
# };
#
# systemd.timers.snapshot-doyha-edanaher = utils.simple-timer "hourly" "Snapshot doyha homedir hourly";
systemd.services.snapshot-doyha-edanaher-to-borg = {
description = "Copy doyha homedir snapshots to borg";
path = with pkgs; [ bash borgbackup utillinux exim ];
serviceConfig = {
User = "root";
ExecStart = periodimail.wrap { interval = two-days; script = "/mnt/snapshots-borg/borg/do.sh"; service = "snapshot-doyha-edanaher-to-borg"; };
};
};
systemd.timers.snapshot-doyha-edanaher-to-borg = utils.simple-timer "daily" "Copy doyha homedir snapshots to borg daily";
};
options = {
host.doyha-backups = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Run doyha backup scripts";
};
};
};
}