Check and install rsync if missing

This commit is contained in:
2021-03-28 23:39:46 +02:00
parent 52d03c3730
commit c75ec7ddeb

View File

@@ -1,10 +1,12 @@
#!/bin/bash
toolName=backup
toolBin=rsync
# Get script working directory
# (when called from a different directory)
WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
APTOPT=
CONFIG=0
CONFIG_FILE_NAME="${toolName}.cfg"
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
@@ -15,7 +17,12 @@ step_config() {
CONFIG=1
else
echoerr " [E] Check output for errors"
# End if no configuration file exists
[ $DRY -eq 0 ] && return -1
fi
[ $QUIET -ne 0 ] && APTOPT="-y"
return 0
}
step_1_info() {
@@ -145,15 +152,31 @@ step_3() {
echoerr " [E] Backup target (${buTarget}) is not writable"
exit 1
fi
checkInstalled
exep "mv -f ${buTarget}/${buLog}0.log /tmp/${buLog}1.log 2>/dev/null"
exep "rsync -avxHAX --delete --info=stats2 ${buExcludes[*]} ${tmpSource} ${tmpTarget} > /tmp/${buLog}0.log"
exep "$toolBin -avxHAX --delete --info=stats2 ${buExcludes[*]} ${tmpSource} ${tmpTarget} > /tmp/${buLog}0.log"
exe mv -f /tmp/${buLog}*.log ${buTarget}
exe sync
exep "mount -o ro,remount '${buTarget}' >>/dev/null 2>&1"
}
VERSION_SEQREV=10
step_100_info() { echo "Install $toolBin"; }
step_100_alias() { ALIAS="install"; }
step_100() {
exe apt update
exe apt install $toolBin $APTOPT
}
checkInstalled() {
command -v $toolBin >>/dev/null
if [ $? -ne 0 ] ; then
step install
fi
toolBin="$(command -v $toolBin)"
}
VERSION_SEQREV=12
. /usr/local/bin/sequencer.sh