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