zMinutiae - xenophon61/Znapzend-recipes-for-mixed-MacOS-Linux-environment GitHub Wiki
Waking up a destination machine using WOL
The most transparent way to wake up a target MacOS system for znapzend transfers, is to edit the ~/.ssh/config
file on the host. The rationale is to inject a WOL command whenever ssh
(i.e. the znapzend daemon) tries to access the destination system.
Here's an excerpt
user@host-iMac ~ % cat ~/.ssh/config
Match host destination.local exec "/usr/local/bin/wakeonlan ax:ax:5x:bx:7x:bx &"
Obviously, the wakeonlan
command must be installed as outlined previously.
Running a script on the destination, to check (and return) a control condition
This is relevant to the skipOnPreSendCmdFail
optional daemon feature, allowing the znapzend backup plan to check for a condition and, depending on the result, proceed or abort the transfer.
Here's a sample excerpt, checking for hung zfs recv
processes
dst_b=username@destinationserver:zpoolname/dataset
dst_b_mbuffer=off
dst_b_mbuffer_size=1G
dst_b_plan=1weeks=>1days,1months=>1days
dst_b_precmd=/usr/bin/ssh -A username@destinationserver "/Users/username/DontZEND.sh"
dst_b_pstcmd=off
And here's the control script
❯ cat DontZEND.sh
#!/bin/bash
# check to see if there is a pending zfs recv process
#
check_zfs_recv()
{
/usr/bin/pgrep -fl 'zfs recv'
myvar=$?
let myvar+=-1
echo -n "[" $myvar "] " >> dont.log
date >> dont.log
echo "------------------------------------------------------------------------------------" >> dont.log
arcstat >> dont.log
pgrep -fl 'zfs recv' >> dont.log
echo "------------------------------------------------------------------------------------" >> dont.log
# May 18, 2024 - set to readony, will only log and return suxess
#
# exit $myvar
exit 0
# 0 = no zfs recv running
# any other = block znapzend at host
}
check_zfs_recv
echo “This line will not be printed”