Systemd service for backing up via ZFS snapshot with send/recv

310 views
Skip to first unread message

Mark Gardner

unread,
Dec 30, 2017, 5:23:14 PM12/30/17
to nix-...@googlegroups.com
Goal: schedule ZFS snapshots and use send/recv to replicate to a backup server.

Options: I considered sanoid/syncoid, zfsnap, zap, zrep, and znapzend. I chose the latter because it is the only one already in NixOS.

Issue: installing znapzend package doesn't start the daemon. I am trying to create a config that will generate the znapzend.service file following the example in github (https://github.com/oetiker/znapzend/blob/master/init/znapzend.service) but my NixOS and systemd foo are not up to the task. Here is what I have so far:

systemd.services.znapzend = {
  description = "ZnapZend - ZFS Backup Service";
  documentation = "man:znapzend";
  after = [ "zfs-import-dpool.service" ];
  wants = [ "zfs-import-dpool.service" ];
  wantedBy = [ "multi-user.target" ];
  serviceConfig = {
    Type = "forking";
    ExecStart = "${pkgs.znapzend}/bin/znapzend --daemonize";
    ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
    Restart = "on-failure";
  };
};

Also, I am not happy with this because the pool name (dpool) is hard-coded into the service file. (I found the dependency on dpool by "systemctl list-units | grep zfs".) I don't know how to generalize the dependency to the import of all pools. How should I be doing it? More generally, what do you do to start the znapzen daemon?

Second question: how do you specify the setup rather than running znapzendzetup by hand?

Note: I am willing to entertain other ways of accomplishing the goal. Please enlighten me if you know of a alternate/better way...

​Mark
--
Mark Gardner
--

Silvan Mosberger

unread,
Dec 30, 2017, 5:28:33 PM12/30/17
to Mark Gardner, nix-...@googlegroups.com
You're in luck! There is already a znapzend service available, you don't need to create one yourself. And: My PR that let's you specify the znapzenzetup in configuration.nix just got merged last week! Check it out here: https://github.com/NixOS/nixpkgs/pull/32914 Also contains an example.

Silvan
--
You received this message because you are subscribed to the Google Groups "nix-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nix-devel+...@googlegroups.com.
To post to this group, send email to nix-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nix-devel/CAG%3D_CgDosh%3DdEVF5x3050fQE5gMz0T%3DHtAwC6u3JSmWJxfG-%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Silvan Mosberger

unread,
Dec 30, 2017, 5:30:04 PM12/30/17
to Mark Gardner, nix-...@googlegroups.com
Oh actually correction: it is not merged yet, but I am very sure it's ready for that

On 30 Dec 2017, at 23:23, Mark Gardner <m...@vt.edu> wrote:

--
Reply all
Reply to author
Forward
0 new messages