Added option to not have remote zroot.

This commit is contained in:
Otho 2023-01-08 03:01:38 -05:00
parent dab6a41c38
commit d4598beff5
Signed by: Otho
GPG Key ID: 16C720CD3BBE21D9

View File

@ -63,15 +63,21 @@ list_datasets()
list_remote_datasets() {
while read addr user ssh_port zroot; do
echo "=== $user@$addr $zroot ==="
if [ $zroot ]; then
case $zroot in
*"/") ;;
*) zroot="$zroot/" ;;
esac
fi
if [ $BG_TEST_MODE = "TRUE" ]; then
echo ssh -i ~/.ssh/id_rsa -o port=$ssh_port $user@$addr\
"sh -c 'for dataset in $SEND_DATASETS;
do zfs list -H $zroot/\$dataset;
do zfs list -H $zroot\$dataset;
done'"
else
ssh -i ~/.ssh/id_rsa -o port=$ssh_port $user@$addr \
"sh -c 'for dataset in $SEND_DATASETS;
do zfs list -H $zroot/\$dataset;
do zfs list -H $zroot\$dataset;
done';"
fi
done < sendnodes.tmp
@ -84,8 +90,14 @@ get_latest_snapshot()
get_latest_remote_snapshot()
{
if [ $zroot ]; then
case $zroot in
*"/") ;;
*) zroot="$zroot/" ;;
esac
fi
ssh -i ~/.ssh/id_rsa -o port=$ssh_port $user@$addr \
"zfs list -t snapshot $zroot/$dataset |
"zfs list -t snapshot $zroot\$dataset |
tail -n1|cut -d'@' -f2|cut -d' ' -f 1"
}
@ -104,15 +116,21 @@ zfs_allow_mirrors()
{
while read addr user ssh_port zroot; do
echo "=== $user@$addr $zroot ==="
if [ $zroot ]; then
case $zroot in
*"/") ;;
*) zroot="$zroot/" ;;
esac
fi
if [ $BG_TEST_MODE = "TRUE" ]; then
echo ssh -i ~/.ssh/id_rsa -o port=$ssh_port $user@$addr \
"for dataset in $SEND_DATASETS; do
zfs allow -u $user $MIRROR_PERMS $zroot/\$dataset
zfs allow -u $user $MIRROR_PERMS $zroot\$dataset
done"
else
ssh -i ~/.ssh/id_rsa -o port=$ssh_port $user@$addr \
"for dataset in $SEND_DATASETS; do
zfs allow -u $user $MIRROR_PERMS $zroot/\$dataset
zfs allow -u $user $MIRROR_PERMS $zroot\$dataset
done"
fi
done < sendnodes.tmp
@ -134,17 +152,23 @@ send_latest()
{
while read addr user ssh_port zroot; do
echo "=== $user@$addr $zroot ==="
if [ $zroot ]; then
case $zroot in
*"/") ;;
*) zroot="$zroot/" ;;
esac
fi
for dataset in $SEND_DATASETS; do
origin_snapshot=`get_latest_snapshot $dataset`
if [ $BG_TEST_MODE = "TRUE" ]; then
echo zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot \| \
ssh -i ~/.ssh/id_rsa -o port=$ssh_port $user@$addr \
zfs recv $ZFS_RECV_OPTS $zroot/$dataset
zfs recv $ZFS_RECV_OPTS $zroot$dataset
else
zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot |
ssh -i ~/.ssh/id_rsa -o port=$ssh_port \
$user@$addr \
zfs recv $ZFS_RECV_OPTS $zroot/$dataset
zfs recv $ZFS_RECV_OPTS $zroot$dataset
fi
done
done < sendnodes.tmp
@ -154,6 +178,12 @@ send_increment()
{
while read addr user ssh_port zroot; do
echo "=== $user@$addr $zroot ==="
if [ $zroot ]; then
case $zroot in
*"/") ;;
*) zroot="$zroot/" ;;
esac
fi
for dataset in $SEND_DATASETS; do
origin_snapshot=`get_latest_snapshot`
remote_snapshot=`get_latest_remote_snapshot`
@ -162,13 +192,13 @@ send_increment()
-i $dataset@$remote_snapshot \
$dataset@$origin_snapshot \| \
ssh -i ~/.ssh/id_rsa -o port=$ssh_port $user@$addr \
zfs recv $ZFS_RECV_OPTS $zroot/$dataset
zfs recv $ZFS_RECV_OPTS $zroot$dataset
else
zfs send $ZFS_SEND_OPTS \
-i $dataset@$remote_snapshot \
$dataset@$origin_snapshot |
ssh -i ~/.ssh/id_rsa -o port=$ssh_port $user@$addr \
zfs recv $ZFS_RECV_OPTS $zroot/$dataset
zfs recv $ZFS_RECV_OPTS $zroot$dataset
fi
done
done < sendnodes.tmp