]> Git — Sourcephile - sourcephile-nix.git/blob - hosts/mermet/sanoid.nix
losurdo: lockKernelModules belongs to security
[sourcephile-nix.git] / hosts / mermet / sanoid.nix
1 { pkgs, lib, config, inputs, ... }:
2 let
3 inherit (builtins) readFile;
4 inherit (config.users) users groups;
5 in
6 {
7 users.users.backup = {
8 isSystemUser = true;
9 shell = users.root.shell;
10 group = groups.disk.name;
11 openssh.authorizedKeys.keys = [
12 (readFile (inputs.secrets + "/hosts/losurdo/ssh/backup.ssh-ed25519.pub"))
13 ] ++ users."julm".openssh.authorizedKeys.keys;
14 };
15 systemd.tmpfiles.rules = [
16 "z /dev/zfs 0660 - ${groups."disk".name} -"
17 ];
18 system.activationScripts.backup = ''
19 ${pkgs.zfs}/bin/zfs allow -u ${users.backup.name} bookmark,hold,send rpool
20 ${pkgs.zfs}/bin/zfs allow -u ${users.backup.name} receive,create,mount,rollback rpool/backup
21 '';
22
23 systemd.services.sanoid.serviceConfig.SupplementaryGroups = [ groups."disk".name ];
24 services.sanoid = {
25 enable = true;
26 templates = {
27 local = {
28 autosnap = true;
29 autoprune = true;
30 monthly = 3;
31 };
32 remote = {
33 autosnap = false;
34 autoprune = true;
35 monthly = 3;
36 };
37 };
38 extraArgs = [
39 "--verbose"
40 #"--debug"
41 ];
42 datasets = {
43 "rpool/backup/losurdo/var/postgresql" = {
44 use_template = [ "remote" ];
45 daily = 31;
46 };
47 "rpool/backup/losurdo/var/cryptpad" = {
48 use_template = [ "remote" ];
49 daily = 31;
50 monthly = 0;
51 };
52 };
53 };
54 }