mirror of
https://asciireactor.com/o4data/zfs-backup.git
synced 2024-11-22 04:25:06 +00:00
Added bandwidth speed option.
This commit is contained in:
parent
1397c9c127
commit
cb2303dc62
18
backup.sh
18
backup.sh
@ -21,7 +21,7 @@ ZFS_SEND_OPTS="-pRLe"
|
|||||||
ZFS_SNAPSHOT_OPTS="-r"
|
ZFS_SNAPSHOT_OPTS="-r"
|
||||||
ZFS_RECV_OPTS="-vsu"
|
ZFS_RECV_OPTS="-vsu"
|
||||||
SSH_SEND_OPTS="-Ti ~/.ssh/id_rsa"
|
SSH_SEND_OPTS="-Ti ~/.ssh/id_rsa"
|
||||||
BANDWIDTH_LIMIT="100M"
|
DEF_SPEED="20M"
|
||||||
|
|
||||||
read LOCAL_HOST LOCAL_USER LOCAL_PORT LOCAL_TZ SEND_COMPRESSED < $nodes_file
|
read LOCAL_HOST LOCAL_USER LOCAL_PORT LOCAL_TZ SEND_COMPRESSED < $nodes_file
|
||||||
case $SEND_COMPRESSED in
|
case $SEND_COMPRESSED in
|
||||||
@ -66,7 +66,7 @@ list_datasets()
|
|||||||
}
|
}
|
||||||
|
|
||||||
list_remote_datasets() {
|
list_remote_datasets() {
|
||||||
while read addr user ssh_port zroot; do
|
while read addr user ssh_port zroot speed; do
|
||||||
echo "=== $user@$addr $zroot ==="
|
echo "=== $user@$addr $zroot ==="
|
||||||
if [ $zroot ]; then
|
if [ $zroot ]; then
|
||||||
case $zroot in
|
case $zroot in
|
||||||
@ -122,7 +122,7 @@ zfs_allow_origin()
|
|||||||
|
|
||||||
zfs_allow_mirrors()
|
zfs_allow_mirrors()
|
||||||
{
|
{
|
||||||
while read addr user ssh_port zroot; do
|
while read addr user ssh_port zroot speed; do
|
||||||
echo "=== $user@$addr $zroot ==="
|
echo "=== $user@$addr $zroot ==="
|
||||||
if [ $zroot ]; then
|
if [ $zroot ]; then
|
||||||
case $zroot in
|
case $zroot in
|
||||||
@ -160,7 +160,7 @@ create_snapshots()
|
|||||||
|
|
||||||
send_latest()
|
send_latest()
|
||||||
{
|
{
|
||||||
while read addr user ssh_port zroot; do
|
while read addr user ssh_port zroot speed; do
|
||||||
echo "=== $user@$addr $zroot ==="
|
echo "=== $user@$addr $zroot ==="
|
||||||
if [ $zroot ]; then
|
if [ $zroot ]; then
|
||||||
case $zroot in
|
case $zroot in
|
||||||
@ -174,12 +174,12 @@ send_latest()
|
|||||||
origin_snapshot=`get_latest_snapshot $dataset`
|
origin_snapshot=`get_latest_snapshot $dataset`
|
||||||
if [ $BG_TEST_MODE = "TRUE" ]; then
|
if [ $BG_TEST_MODE = "TRUE" ]; then
|
||||||
echo zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot \| \
|
echo zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot \| \
|
||||||
pv -qL $BANDWIDTH_LIMIT \| \
|
pv -qL ${speed:-$DEF_SPEED} \| \
|
||||||
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
|
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
|
||||||
zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset
|
zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset
|
||||||
else
|
else
|
||||||
zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot |
|
zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot |
|
||||||
pv -qL $BANDWIDTH_LIMIT |
|
pv -qL ${speed:-$DEF_SPEED} |
|
||||||
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
|
||||||
@ -190,7 +190,7 @@ send_latest()
|
|||||||
|
|
||||||
send_increment()
|
send_increment()
|
||||||
{
|
{
|
||||||
while read addr user ssh_port zroot; do
|
while read addr user ssh_port zroot speed; do
|
||||||
echo "=== $user@$addr $zroot ==="
|
echo "=== $user@$addr $zroot ==="
|
||||||
if [ $zroot ]; then
|
if [ $zroot ]; then
|
||||||
case $zroot in
|
case $zroot in
|
||||||
@ -207,14 +207,14 @@ send_increment()
|
|||||||
echo zfs send $ZFS_SEND_OPTS \
|
echo zfs send $ZFS_SEND_OPTS \
|
||||||
-i $dataset@$remote_snapshot \
|
-i $dataset@$remote_snapshot \
|
||||||
$dataset@$origin_snapshot \| \
|
$dataset@$origin_snapshot \| \
|
||||||
pv -qL $BANDWIDTH_LIMIT \| \
|
pv -qL ${speed:-$DEF_SPEED} \| \
|
||||||
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
|
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
|
||||||
zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset
|
zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset
|
||||||
else
|
else
|
||||||
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 $BANDWIDTH_LIMIT |
|
pv -qL ${speed:-$DEF_SPEED} |
|
||||||
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
|
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
|
||||||
zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset
|
zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user