oetiker / znapzend

zfs backup with remote capabilities and mbuffer integration.
www.znapzend.org
GNU General Public License v3.0
613 stars 137 forks source link

zfs: command not found #327

Closed UnConundrum closed 3 years ago

UnConundrum commented 6 years ago

I'm trying to create my first config and I'm finding two errors, first of which is zfs not found. I'm logged in as root and which zfs reports /sbin/zfs. That said, I believe the error is referring to the destination server. I've encountered this issue with a normal zfs send/receive situation which was resolved by including the full path to zfs on the destination (in my case, /usr/local/bin/zfs. Apparently ssh doesn't execute a login shell when executing a command and the paths aren't set. For now, I'm assuming that the 2nd error is a result of the first.

Is there any way to set the path to zfs on the destination?

Here is my create command

`znapzendzetup create --recursive --tsformat='%Y-%m-%d-%H%M%S' \

SRC '7d=>1h,30d=>4h,90d=>1w,1y=>1m' new_10T/mysql \ DST:a '7d=>1h,30d=>4h,90d=>1w,1y=>1m,10y=>1y' four_T/snaps \ DST:b '7d=>1h,30d=>4h,90d=>1w,1y=>1m,10y=>1y' whp:archive/snaps

bash: zfs: command not found backup plan: new_10T/mysql dst_a = four_T/snaps dst_a_plan = 7days=>1hour,30days=>4hours,90days=>1week,1year=>1month,10years=>1year dst_b = whp:archive/snaps dst_b_plan = 7days=>1hour,30days=>4hours,90days=>1week,1year=>1month,10years=>1year WARNING: destination 'whp:archive/snaps' does not exist, will be ignored! `

UnConundrum commented 6 years ago

I got past (I think) the first issue by adding a ForceCommand to my ssh_config on the receiving side. At least, the error report is gone. That did not resolve the missing file system. Zfs list on whp confirms that archive/snaps exists, and I've confirmed that readonly is false and that the filesystem is mounted.

I can ssh whp without difficulty or the need for a password

I should add that the receiving server is running OS X. High Sierra and that I have been unable to get mbuffer installed on it, that's why I left off the mbuffer switches.

UnConundrum commented 6 years ago

I got it figured out. For anyone else with a similar issue, I continued with ForceCommand in sshd_conf. The command calls a bash script the contents of which are:

`#!/usr/bin/env bash -l

cmd="$SSH_ORIGINAL_COMMAND"

PATH=

eval sudo $cmd `

SlothOfAnarchy commented 5 years ago

Alternatively, you can prepend your key in ~/.ssh/authorized_keys with command="sudo sh -c \"$SSH_ORIGINAL_COMMAND\""

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

eccen commented 3 years ago

It's super dangerous to force every ssh command to be "sudo". Rather than doing that, we should address the real problem, which is an incorrectly defined ssh $PATH variable:

machine:~ user$ ssh localhost zfs sh: zfs: command not found

First get the path of your zfs command: machine:~ user$ which zfs /usr/local/zfs/bin/zfs

It's probably not in your ssh PATH (if it is, then this fix won't solve your problem): machine:~ user$ cat ~/.ssh/environment PATH=/opt/local/bin:/usr/bin

Yep, it's missing, so let's add our zfs path directory to the beginning of the PATH declaration in ~/.ssh/environment (colon separated; creating the file if needed): PATH=/usr/local/zfs/bin/:/opt/local/bin:/usr/bin

Now it should work! machine:~ user$ ssh localhost zfs missing command usage: zfs command args ...