add limit

This commit is contained in:
Jochen Welzel 2021-01-06 11:07:05 +01:00
parent dfaeaac441
commit 6dee2475b2
1 changed files with 5 additions and 3 deletions

View File

@ -8,22 +8,24 @@ helpFunction()
echo -e "\t-t Backup target host name"
echo -e "\t-s VM source zfs dataset"
echo -e "\t-d Backup target zfs dataset"
echo -e "\t-l Limit Bandwith"
exit 1 # Exit script after printing help
}
while getopts "v:t:s:d:" opt
while getopts "v:t:s:d:l:" opt
do
case "$opt" in
v ) VM="$OPTARG" ;;
t ) DESTHOST="$OPTARG" ;;
s ) SRCZFS="$OPTARG" ;;
d ) DESTZFS="$OPTARG" ;;
l ) LIMIT="$OPTARG" ;;
? ) helpFunction ;; # Print helpFunction in case parameter is non-existent
esac
done
# Print helpFunction in case parameters are empty
if [ -z "$VM" ] || [ -z "$DESTHOST" ] || [ -z "$DESTZFS" ] || [ -z "$SRCZFS" ]
if [ -z "$VM" ] || [ -z "$DESTHOST" ] || [ -z "$DESTZFS" ] || [ -z "$SRCZFS" ] || [ -z "$LIMIT" ]
then
echo "Some or all of the parameters are empty";
helpFunction
@ -86,7 +88,7 @@ then
LASTSNAP="backup_$LASTBACKUP"
zfs send -i "$SRCZFS"@"$LASTSNAP" "$SRCZFS"@"$SNAPNAME" | pv -L 500M | ssh $DESTHOST sudo zfs recv -F $DESTZFS
else
zfs send "$SRCZFS"@"$SNAPNAME" | pv -L 500M | ssh $DESTHOST sudo zfs recv -F $DESTZFS
zfs send "$SRCZFS"@"$SNAPNAME" | pv -L $LIMIT | ssh $DESTHOST sudo zfs recv -F $DESTZFS
fi
if [ $? -eq 0 ]
then