Changed method for setting up run command.

This commit is contained in:
Otho 2023-01-16 22:04:39 -05:00
parent 7651cf44ec
commit ab3edb1d51
Signed by: Otho
GPG Key ID: 16C720CD3BBE21D9

View File

@ -98,18 +98,15 @@ list_remote_datasets() {
*) zroot="$zroot/" ;;
esac
fi
if [ $BG_TEST_MODE = "TRUE" ]; then
echo ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr\
"sh -c 'for dataset in $SEND_DATASETS; do
run_cmd="
sh -c 'for dataset in $SEND_DATASETS; do
dataset=`echo \\$dataset|cut -d: -f2`
zfs list -H $zroot\$dataset;
done'"
if [ $BG_TEST_MODE = "TRUE" ]; then
echo ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr $run_cmd
else
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
"sh -c 'for dataset in $SEND_DATASETS; do
dataset=`echo \\$dataset|cut -d: -f2`
zfs list -H $zroot\$dataset;
done';"
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr $run_cmd
fi
done < sendnodes.tmp
}
@ -154,18 +151,17 @@ zfs_allow_mirrors()
*) zroot="$zroot/" ;;
esac
fi
run_cmd="
for dataset in $SEND_DATASETS; do
dataset=`echo \\$dataset|cut -d: -f2`
zfs allow -u $user $MIRROR_PERMS $zroot\$dataset
done
"
if [ $BG_TEST_MODE = "TRUE" ]; then
echo ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
"for dataset in $SEND_DATASETS; do
dataset=`echo \\$dataset|cut -d: -f2`
zfs allow -u $user $MIRROR_PERMS $zroot\$dataset
done"
echo ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr $run_cmd
else
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
"for dataset in $SEND_DATASETS; do
dataset=`echo \\$dataset|cut -d: -f2`
zfs allow -u $user $MIRROR_PERMS $zroot\$dataset
done"
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr $run_cmd
fi
done < sendnodes.tmp
}
@ -197,17 +193,17 @@ send_latest()
dataset=`echo $dataset|cut -d: -f1`
debug "Processing $dataset (remote $remote_dataset)."
origin_snapshot=`get_latest_snapshot $dataset`
if [ $BG_TEST_MODE = "TRUE" ]; then
echo zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot \| \
pv -qL ${speed:-$DEF_SPEED} \| \
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset
else
run_cmd="
zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot |
pv -qL ${speed:-$DEF_SPEED} |
ssh $SSH_SEND_OPTS -o port=$ssh_port \
$user@$addr \
zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset
"
if [ $BG_TEST_MODE = "TRUE" ]; then
echo $run_cmd
else
$run_cmd
fi
done
done < sendnodes.tmp
@ -228,20 +224,18 @@ send_increment()
dataset=`echo $dataset|cut -d: -f1`
origin_snapshot=`get_latest_snapshot`
remote_snapshot=`get_latest_remote_snapshot`
if [ $BG_TEST_MODE = "TRUE" ]; then
echo zfs send $ZFS_SEND_OPTS \
-i $dataset@$remote_snapshot \
$dataset@$origin_snapshot \| \
pv -qL ${speed:-$DEF_SPEED} \| \
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset
else
run_cmd="
zfs send $ZFS_SEND_OPTS \
-i $dataset@$remote_snapshot \
$dataset@$origin_snapshot |
pv -qL ${speed:-$DEF_SPEED} |
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset
"
if [ $BG_TEST_MODE = "TRUE" ]; then
echo $run_cmd
else
$run_cmd
fi
done
done < sendnodes.tmp