jgoerzen / simplesnap

A simple and powerful way to send ZFS snapshots across a network
GNU General Public License v3.0
49 stars 15 forks source link

simplesnap fails immediately when invoked from CRON on Ubuntu 20.04.3 #28

Closed rtrevellyan closed 2 years ago

rtrevellyan commented 3 years ago

The error from CRON is: /usr/sbin/simplesnap: line 179: zfs: command not found

That line is where simplesnap is trying to find the mountpoint for the store dataset: MOUNTPOINT="`zfs list -H -o mountpoint -t filesystem \"${STORE}\"`"

The packaged version on Ubuntu 20.04.3 is old. The equivalent line in the current version is #195. That appears to be the only place where simplesnap invokes zfs without specifying a full path. The solution in my case is to replace that line with: MOUNTPOINT="`/sbin/zfs list -H -o mountpoint -t filesystem \"${STORE}\"`"

This issue does not occur when invoking simplesnap from the CLI.

HRio commented 2 years ago

setting up PATH is some thing that should be done in the crontab, from man -S5 crontab on Debian

Several environment variables are set up automatically by the cron(8) daemon.  SHELL is set to /bin/sh, and LOGNAME and HOME are set from the /etc/passwd line of the crontab's owner.  PATH is set to
       "/usr/bin:/bin".  HOME, SHELL, and PATH may be overridden by settings in the crontab;
EXAMPLE SYSTEM CRON FILE
       The following lists the content of a regular  system-wide  crontab  file.   Unlike  a  user's
       crontab, this file has the username field, as used by /etc/crontab.

       # /etc/crontab: system-wide crontab
       # Unlike any other crontab you don't have to run the `crontab'
       # command to install the new version when you edit this file
       # and files in /etc/cron.d.  These files also have username fields,
       # that none of the other crontabs do.

       SHELL=/bin/sh
       PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

@jgoerzen a3a46d07e224c34fb824fdcd69d01842ec280682 broke portability to non Debian based platforms.