allanjude / zxfer

A continuation of development on zxfer, a popular script for managing ZFS snapshot replication
BSD 2-Clause "Simplified" License
123 stars 40 forks source link

ZXFER Failed to retrieve datasets from the destination #60

Open xflou opened 1 year ago

xflou commented 1 year ago

Hello,

Looking for some suggestions or ideas on a problem I've encountered using zxfer.

I have an existing system with an existing zfs pool that I'm trying to copy over to another system.

For some reason, I am able to run the zxfer command interactively with no issues; however, when I attempt to run the same command from a bash script, it fails.

Below is the actual output and messages:

when running the following command from within a shell script, it returns the following error messages:

/usr/local/sbin/zxfer -F -k -P -R remotepool -O root@remotesystem localpool /usr/local/sbin/zxfer: 681: list: not found Failed to retrieve datasets from the destination

when starting the same command interactively a shell terminal window at the command line, it seems to work:

In fact, the command starts, it pulls the snapshots across from the remotesystem ; which I can see on the local system using "zfs list -t snap" command.

/usr/local/sbin/zxfer -F -k -P -R remotepool -O root@remotesystem localpool

Has anyone seen or experienced this issue before that can share how they fixed it and or anyone have any suggestions.

I would appreciate it.

Thanks!

allanjude commented 1 year ago

This most likely means that zxfer is failing to find the zfs binary on your system It does LZFS=$( which zfs ) so if that returns blank, it might try to just run $LZFS list and generate that error.

It should catch that and fail, but maybe it is not.

xflou commented 1 year ago

Thank you Allan, I will double check that. I appreciate the response.

xflou commented 1 year ago

Hi Allen,

I just tested a few additional things based on what you suggested.

  1. I ran a “which zfs” on the remote system via ssh and on the local system:

output: logged into the remote system at the command line: which zfs /usr/sbin/zfs

output: same command run on the local system to the remote via ssh ssh remote system which zfs /usr/sbin/zfs

output: same command run on the local system which zfs /usr/sbin/zfs

Basically, I made sure the zfs program was found in the correct place so zxfer would find it.

  1. based on what I found, I turned on debug in the “/usr/local/sbin/zxfer” script.

    What I found is the following:

    a. When running the command string from the shell command-line(interactively) as seen below, ZXFER is able to return a value for “which zfs” which is attached to the LZFS variable. command: “/usr/local/sbin/zxfer -F -k -P -R remotepool -O root@remotesystem localpool”

    Variable information found:

    • backup_file_extension=.zxfer_backup_info
    • backup_file_contents=
    • source_os=
    • dest_os=
    • uname
    • home_os=Linux
    • trailing_slash=0
    • which zfs ##<——
    • LZFS=/usr/sbin/zfs ##<——
    • RZFS=/usr/sbin/zfs
    • LCAT=
    • which awk
    • AWK=/usr/bin/awk
    • date +%s
    • current_date=1687455044
    • snapshot_name=zxfertempsnap
    • dont_write_backup=0
    • ensure_writable=0

At the end of the run it begins to pull the snapshots as it normally should.

B. When running the same command string from a shell script and launched via cron(batch), the results that I am finding are that the LZFS variable is “empty” as you suspected it would be:

Variable information NOT found:

Then the script continues and ends with the same message listed below:

Note: I thought about hard coding the value in the ZXFER script:

LZFS=/usr/sbin/zfs

However, there must be a better option as I’m concerned about breaking something else.

Thanks again for your help!

xflou commented 1 year ago

Hi Allan,

Just a quick update. I went ahead and hard coded the path for "zfs" in the zxfer script, and it is now running fine from cron.

LZFS=$( which zfs )

LZFS="/usr/sbin/zfs"

Additionally tried to use back tics but that failed as well. Using LZFS=$( which zfs) And LZFS=which zfs

both failed.

So looks like only hardcoding the path seems to work.

Additional info:

Local system: Ubuntu 20.04 remote system: Ubuntu 18.04.5

Thanks