]> Git — Sourcephile - julm/julm-nix.git/blob - hosts/patate/backup.nix
nebula: comment about possible cipher
[julm/julm-nix.git] / hosts / patate / backup.nix
1 { pkgs, 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 SUBSYSTEM=="block", KERNEL=="sd*", ENV{ID_SERIAL}=="WDC_WD10JPVT-22A1YT0_WD-WX21AC2F3987", \
44 ACTION=="add", ENV{SYSTEMD_WANTS}+="zfs-local-backup-home@WD10JPVT.service"
45 # See https://github.com/systemd/systemd/issues/7587#issuecomment-381428545
46 SUBSYSTEM=="block", KERNEL=="sd*", ENV{ID_SERIAL}=="WDC_WD10JPVT-22A1YT0_WD-WX21AC2F3987", \
47 ACTION=="remove", RUN+="${pkgs.systemd}/bin/systemctl stop --no-block zfs-local-backup-home@WD10JPVT.service"
48
49 SUBSYSTEM=="block", KERNEL=="sd*", ENV{ID_FS_LABEL}=="GE_SP", \
50 ACTION=="add", ENV{SYSTEMD_USER_WANTS}+="rsync-backup@GE_SP.service"
51 SUBSYSTEM=="block", KERNEL=="sd*", ENV{ID_FS_LABEL}=="GE_SP", \
52 ACTION=="remove", RUN+="${pkgs.systemd}/bin/systemctl stop --no-block zfs-import@off3.service"
53 '';
54 programs.bash.shellAliases = {
55 mount-backup-WD10JPVT = "mount-zfs-backup WD10JPVT";
56 };
57 }