-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathamy.nix
85 lines (79 loc) · 2.46 KB
/
amy.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
{ lib, config, pkgs, ... }: {
networking.hostName = "amy";
networking.retiolum = {
ipv4 = "10.243.29.181";
ipv6 = "42:0:3c46:1551:1906:bc7c:801f:3c4";
};
services.nfs.server.enable = true;
services.nfs.server.exports = ''
/home/ ${lib.concatMapStringsSep " "
(host:
''${host.ipv4}(rw,nohide,insecure,no_subtree_check,no_root_squash)'')
(lib.attrValues config.networking.doctorwho.hosts)}
'';
services.borgbackup.jobs.joerg = {
paths = [
"/home/joerg"
];
doInit = true;
repo = "[email protected]:.";
preHook = ''
eval $(ssh-agent)
ssh-add /etc/nixos/secrets/borgbackup-ssh-key
'';
postHook = ''
cat > /var/log/telegraf/borgbackup-amy <<EOF
task,frequency=daily last_run=$(date +%s)i,state="$([[ $exitStatus == 0 ]] && echo ok || echo fail)"
EOF
'';
extraArgs = "--lock-wait 900";
encryption.mode = "none";
compression = "auto,zstd";
startAt = "daily";
prune.keep = {
within = "1d"; # Keep all archives from the last day
daily = 7;
weekly = 4;
monthly = 0;
};
};
systemd.timers.borgbackup-job-joerg = {
timerConfig.OnCalendar = lib.mkForce "04:00:00";
};
services.borgbackup.jobs.all-homes = {
paths = [
"/home"
];
doInit = true;
repo = "/mnt/backup/borgbackup";
preHook = ''
${pkgs.sshfs}/bin/sshfs -oIdentityFile=/etc/nixos/secrets/borgbackup-ssh-key -oPort=22222 [email protected]:/csce/datastore/inf/users/s1443541 /mnt/backup
'';
postHook = ''
cat > /var/log/telegraf/borgbackup-datastore <<EOF
task,frequency=daily last_run=$(date +%s)i,state="$([[ $exitStatus == 0 ]] && echo ok || echo fail)"
EOF
'';
encryption = {
mode = "repokey";
passCommand = "cat /etc/nixos/secrets/borgbackup-password";
};
compression = "auto,zstd";
startAt = "daily";
prune.keep = {
within = "1d"; # Keep all archives from the last day
daily = 7;
weekly = 4;
monthly = 0;
};
};
# hide sshfs from the system
systemd.services.borgbackup-job-all-homes.serviceConfig.PrivateMounts = true;
systemd.services.borgbackup-job-all-homes.serviceConfig.ReadWritePaths = [ "/var/log/telegraf" ];
systemd.services.borgbackup-job-joerg.serviceConfig.ReadWritePaths = [ "/var/log/telegraf" ];
fileSystems."/home" = {
device = "zroot/root/home";
fsType = "zfs";
};
system.stateVersion = "19.09";
}