This commit is contained in:
Otho 2023-01-09 01:23:59 -05:00
parent d4598beff5
commit 706aab7d4f
Signed by: Otho
GPG Key ID: 16C720CD3BBE21D9
2 changed files with 13 additions and 11 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
datasets.txt
nodes.txt
old-snapshot.txt
sendnodes.tmp

View File

@ -17,9 +17,10 @@ datasets_file="datasets.txt"
if [ ! -f $nodes_file ]; then echo "No nodes specified."; exit 2; fi
if [ ! -f $datasets_file ]; then echo "No datasets specified."; exit 3; fi
ZFS_SEND_OPTS="-R"
ZFS_SEND_OPTS="-vpRLe"
ZFS_SNAPSHOT_OPTS="-r"
ZFS_RECV_OPTS="-svu"
SSH_SEND_OPTS="-Ti ~/.ssh/id_rsa"
read LOCAL_HOST LOCAL_USER LOCAL_PORT LOCAL_TZ SEND_COMPRESSED < $nodes_file
case $SEND_COMPRESSED in
@ -27,7 +28,7 @@ case $SEND_COMPRESSED in
esac
ORIGIN_PERMS="send,snapshot,hold"
MIRROR_PERMS="compression,receive,create,mount,mountpoint"
MIRROR_PERMS="compression,receive,create,mount,mountpoint,readonly,jailed"
SEND_DATASETS=""
SNAPSHOT_DATASETS=""
@ -70,12 +71,12 @@ list_remote_datasets() {
esac
fi
if [ $BG_TEST_MODE = "TRUE" ]; then
echo ssh -i ~/.ssh/id_rsa -o port=$ssh_port $user@$addr\
echo ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr\
"sh -c 'for dataset in $SEND_DATASETS;
do zfs list -H $zroot\$dataset;
done'"
else
ssh -i ~/.ssh/id_rsa -o port=$ssh_port $user@$addr \
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
"sh -c 'for dataset in $SEND_DATASETS;
do zfs list -H $zroot\$dataset;
done';"
@ -96,7 +97,7 @@ get_latest_remote_snapshot()
*) zroot="$zroot/" ;;
esac
fi
ssh -i ~/.ssh/id_rsa -o port=$ssh_port $user@$addr \
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
"zfs list -t snapshot $zroot\$dataset |
tail -n1|cut -d'@' -f2|cut -d' ' -f 1"
}
@ -123,12 +124,12 @@ zfs_allow_mirrors()
esac
fi
if [ $BG_TEST_MODE = "TRUE" ]; then
echo ssh -i ~/.ssh/id_rsa -o port=$ssh_port $user@$addr \
echo ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
"for dataset in $SEND_DATASETS; do
zfs allow -u $user $MIRROR_PERMS $zroot\$dataset
done"
else
ssh -i ~/.ssh/id_rsa -o port=$ssh_port $user@$addr \
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
"for dataset in $SEND_DATASETS; do
zfs allow -u $user $MIRROR_PERMS $zroot\$dataset
done"
@ -162,11 +163,11 @@ send_latest()
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 \
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
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 \
ssh $SSH_SEND_OPTS -o port=$ssh_port \
$user@$addr \
zfs recv $ZFS_RECV_OPTS $zroot$dataset
fi
@ -191,13 +192,13 @@ send_increment()
echo zfs send $ZFS_SEND_OPTS \
-i $dataset@$remote_snapshot \
$dataset@$origin_snapshot \| \
ssh -i ~/.ssh/id_rsa -o port=$ssh_port $user@$addr \
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
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 \
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
zfs recv $ZFS_RECV_OPTS $zroot$dataset
fi
done