mirror of
https://asciireactor.com/o4data/zfs-backup.git
synced 2024-11-24 19:05:06 +00:00
Implemented new run approach.
This commit is contained in:
parent
5ede78973a
commit
d41208cdfe
54
backup.sh
54
backup.sh
@ -39,6 +39,15 @@ debug()
|
||||
fi
|
||||
}
|
||||
|
||||
run_send_recv()
|
||||
{
|
||||
if [ $ZB_TEST_MODE = "TRUE" ]; then
|
||||
echo "$send_cmd | $pv_cmd | $recv_cmd"
|
||||
else
|
||||
$send_cmd | $pv_cmd | $recv_cmd
|
||||
fi
|
||||
}
|
||||
|
||||
set_compression() {
|
||||
case $SEND_COMPRESSED in
|
||||
[tTyY]*) ZFS_SEND_OPTS="$ZFS_SEND_OPTS -c"
|
||||
@ -151,17 +160,16 @@ zfs_allow_mirrors()
|
||||
*) zroot="$zroot/" ;;
|
||||
esac
|
||||
fi
|
||||
run_cmd="
|
||||
remote_cmd="
|
||||
for dataset in $SEND_DATASETS; do
|
||||
dataset=`echo \\$dataset|cut -d: -f2`
|
||||
zfs allow -u $user $MIRROR_PERMS $zroot\$dataset
|
||||
done
|
||||
"
|
||||
if [ $ZB_TEST_MODE = "TRUE" ]; then
|
||||
echo ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr $run_cmd
|
||||
|
||||
echo ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr $remote_cmd
|
||||
else
|
||||
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr $run_cmd
|
||||
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr $remote_cmd
|
||||
fi
|
||||
done < sendnodes.tmp
|
||||
}
|
||||
@ -193,18 +201,13 @@ send_latest()
|
||||
dataset=`echo $dataset|cut -d: -f1`
|
||||
debug "Processing $dataset (remote $remote_dataset)."
|
||||
origin_snapshot=`get_latest_snapshot $dataset`
|
||||
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 \
|
||||
send_cmd="zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot"
|
||||
pv_cmd="pv -qL ${speed:-$DEF_SPEED}"
|
||||
recv_cmd="
|
||||
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
|
||||
zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset
|
||||
"
|
||||
if [ $ZB_TEST_MODE = "TRUE" ]; then
|
||||
echo $run_cmd
|
||||
else
|
||||
$run_cmd
|
||||
fi
|
||||
"
|
||||
run_send_recv
|
||||
done
|
||||
done < sendnodes.tmp
|
||||
}
|
||||
@ -224,19 +227,16 @@ send_increment()
|
||||
dataset=`echo $dataset|cut -d: -f1`
|
||||
origin_snapshot=`get_latest_snapshot`
|
||||
remote_snapshot=`get_latest_remote_snapshot`
|
||||
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
|
||||
send_cmd="
|
||||
zfs send $ZFS_SEND_OPTS -i $dataset@$remote_snapshot \
|
||||
$dataset@$origin_snapshot
|
||||
"
|
||||
if [ $ZB_TEST_MODE = "TRUE" ]; then
|
||||
echo $run_cmd
|
||||
else
|
||||
$run_cmd
|
||||
fi
|
||||
pv_cmd="pv -qL ${speed:-$DEF_SPEED}"
|
||||
recv_cmd="
|
||||
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
|
||||
zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset
|
||||
"
|
||||
run_send_recv
|
||||
done
|
||||
done < sendnodes.tmp
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user