]> Git — Sourcephile - julm/julm-nix.git/blob - hosts/patate/backup.nix
dnscrypt-proxy2: remove erroneous config
[julm/julm-nix.git] / hosts / patate / backup.nix
1 { pkgs, lib, config, hostName, ... }:
2 with builtins;
3 {
4 imports = [
5 backup/zfs-backup.nix
6 backup/rsync-backup.nix
7 ];
8 # Take regular snapshots, and prune old ones
9 services.sanoid = {
10 enable = true;
11 extraArgs = [ "--verbose" ];
12 datasets = {
13 "${hostName}/home" = {
14 autosnap = true;
15 autoprune = true;
16 hourly = 24;
17 daily = 3;
18 monthly = 0;
19 yearly = 0;
20 recursive = true;
21 };
22 "${hostName}/home/Documents" = {
23 autosnap = true;
24 autoprune = true;
25 hourly = 24;
26 daily = 31;
27 monthly = 0;
28 yearly = 0;
29 recursive = true;
30 };
31 "${hostName}/home/Downloads" = {
32 autosnap = false;
33 autoprune = false;
34 };
35 "${hostName}/home/Videos" = {
36 autosnap = false;
37 autoprune = false;
38 };
39 };
40 };
41 # Trigger backups when disks are plugged
42 services.udev.extraRules = ''
43 ACTION=="add", SUBSYSTEM=="block", KERNEL=="sd*", ENV{ID_SERIAL}=="WDC_WD10JPVT-22A1YT0_WD-WX21AC2F3987", ENV{SYSTEMD_WANTS}+="zfs-local-backup-home@WD10JPVT.service", ENV{SYSTEMD_ALIAS}="/sys/subsystem/usb/WD10JPVT"
44 # See https://github.com/systemd/systemd/issues/7587#issuecomment-381428545
45 ACTION=="remove", SUBSYSTEM=="block", KERNEL=="sd*", ENV{ID_SERIAL}=="WDC_WD10JPVT-22A1YT0_WD-WX21AC2F3987", TAG+="systemd"
46
47 ACTION=="add", SUBSYSTEM=="block", KERNEL=="sd*", ENV{ID_FS_LABEL}=="GE_SP", ENV{SYSTEMD_USER_WANTS}+="rsync-backup@GE_SP.service", ENV{SYSTEMD_ALIAS}="/sys/subsystem/usb/GE_SP"
48 ACTION=="remove", SUBSYSTEM=="block", KERNEL=="sd*", ENV{ID_FS_LABEL}=="GE_SP", TAG+="systemd"
49 '';
50 programs.bash.shellAliases = {
51 mount-backup-WD10JPVT = "mount-zfs-backup WD10JPVT";
52 };
53 }