Skip to content

Haumea: znapzend configuration

Graham Christensen edited this page Mar 20, 2020 · 9 revisions

Setting a server to receive snapshots

In this document, I call the receiving server "target". The receiving end must run ZFS. In this snippet, I assume the following about "target":

  • the backups will be stored in a pool named mass
  • the dataset will be named mass/nixos-org/haumea
  • it will have a user named "nixosfoundationbackups"

In the receiving server's configuration, define a user like this:

{
  users.users.nixosfoundationbackups = {
    # the user needs to be able to execute commands remotely, thus having a shell:
    isNormalUser = true;
    openssh.authorizedKeys.keys = [
      "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOyyr/4fMKQ1fwa5DjFVIHQLchr4EKcOWEI++gYBTbWF root@haumea"
    ];
  };
}

Then create the dataset:

target# zfs create mass/nixos-org/haumea
target# zfs set canmount=off mass/nixos-org/haumea
target# zfs allow -u nixosfoundationbackups create,mount,receive,userprop mass/nixos-org/haumea

It is possible this is also required, but let's try without it for now (2020-03-20 - delete if this comment is still here in 1 month, since we clearly didn't need it), and only run it if we must:

target# zfs allow -c create,mount,receive,userprop mass/nixos-org/haumea

Then edit Haumea's expression and add your server to Haumea's list of targets:

{
  services.znapzend = {
    zetup = {
      "rpool/safe" = {
        destinations.your-servers-name = {
          plan = "1hour=>5min,4day=>1hour,1week=>1day,1year=>1week,10year=>1month";
          host = "nixosfoundationbackups@your-servers-address";
          dataset = "mass/nixos-org/haumea/safe";
        };
      };
    };
  };
}