mirror of
https://asciireactor.com/o4data/zfs-backup.git
synced 2024-11-22 02:15:05 +00:00
Changed method for setting up run command.
This commit is contained in:
parent
7651cf44ec
commit
ab3edb1d51
58
backup.sh
58
backup.sh
@ -98,18 +98,15 @@ list_remote_datasets() {
|
|||||||
*) zroot="$zroot/" ;;
|
*) zroot="$zroot/" ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
if [ $BG_TEST_MODE = "TRUE" ]; then
|
run_cmd="
|
||||||
echo ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr\
|
sh -c 'for dataset in $SEND_DATASETS; do
|
||||||
"sh -c 'for dataset in $SEND_DATASETS; do
|
|
||||||
dataset=`echo \\$dataset|cut -d: -f2`
|
dataset=`echo \\$dataset|cut -d: -f2`
|
||||||
zfs list -H $zroot\$dataset;
|
zfs list -H $zroot\$dataset;
|
||||||
done'"
|
done'"
|
||||||
|
if [ $BG_TEST_MODE = "TRUE" ]; then
|
||||||
|
echo ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr $run_cmd
|
||||||
else
|
else
|
||||||
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
|
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr $run_cmd
|
||||||
"sh -c 'for dataset in $SEND_DATASETS; do
|
|
||||||
dataset=`echo \\$dataset|cut -d: -f2`
|
|
||||||
zfs list -H $zroot\$dataset;
|
|
||||||
done';"
|
|
||||||
fi
|
fi
|
||||||
done < sendnodes.tmp
|
done < sendnodes.tmp
|
||||||
}
|
}
|
||||||
@ -154,18 +151,17 @@ zfs_allow_mirrors()
|
|||||||
*) zroot="$zroot/" ;;
|
*) zroot="$zroot/" ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
run_cmd="
|
||||||
|
for dataset in $SEND_DATASETS; do
|
||||||
|
dataset=`echo \\$dataset|cut -d: -f2`
|
||||||
|
zfs allow -u $user $MIRROR_PERMS $zroot\$dataset
|
||||||
|
done
|
||||||
|
"
|
||||||
if [ $BG_TEST_MODE = "TRUE" ]; then
|
if [ $BG_TEST_MODE = "TRUE" ]; then
|
||||||
echo ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
|
echo ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr $run_cmd
|
||||||
"for dataset in $SEND_DATASETS; do
|
|
||||||
dataset=`echo \\$dataset|cut -d: -f2`
|
|
||||||
zfs allow -u $user $MIRROR_PERMS $zroot\$dataset
|
|
||||||
done"
|
|
||||||
else
|
else
|
||||||
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
|
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr $run_cmd
|
||||||
"for dataset in $SEND_DATASETS; do
|
|
||||||
dataset=`echo \\$dataset|cut -d: -f2`
|
|
||||||
zfs allow -u $user $MIRROR_PERMS $zroot\$dataset
|
|
||||||
done"
|
|
||||||
fi
|
fi
|
||||||
done < sendnodes.tmp
|
done < sendnodes.tmp
|
||||||
}
|
}
|
||||||
@ -197,17 +193,17 @@ 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`
|
||||||
if [ $BG_TEST_MODE = "TRUE" ]; then
|
run_cmd="
|
||||||
echo zfs send $ZFS_SEND_OPTS $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
|
|
||||||
else
|
|
||||||
zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot |
|
zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot |
|
||||||
pv -qL ${speed:-$DEF_SPEED} |
|
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
|
||||||
|
"
|
||||||
|
if [ $BG_TEST_MODE = "TRUE" ]; then
|
||||||
|
echo $run_cmd
|
||||||
|
else
|
||||||
|
$run_cmd
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done < sendnodes.tmp
|
done < sendnodes.tmp
|
||||||
@ -228,20 +224,18 @@ 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`
|
||||||
if [ $BG_TEST_MODE = "TRUE" ]; then
|
run_cmd="
|
||||||
echo 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
|
|
||||||
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 ${speed:-$DEF_SPEED} |
|
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
|
||||||
|
"
|
||||||
|
if [ $BG_TEST_MODE = "TRUE" ]; then
|
||||||
|
echo $run_cmd
|
||||||
|
else
|
||||||
|
$run_cmd
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done < sendnodes.tmp
|
done < sendnodes.tmp
|
||||||
|
Loading…
Reference in New Issue
Block a user