allow to backup a specific host

This commit is contained in:
2021-08-30 19:45:32 +02:00
parent 46903a4038
commit 6da9f1fabc
3 changed files with 65 additions and 24 deletions

View File

@@ -26,6 +26,8 @@ else
SSH_KEY=~/.ssh/id_rsa
fi
ARG1="$1"
# Get current date
DATE=$(date +"%Y-%m-%d_%H-%M")
LOG="$CURDIR"/backup.log
@@ -48,6 +50,18 @@ while read -r line; do
if echo "$line" | grep -qE "^\s*(#|$)"; then continue; fi
RHOST=$(echo "$line" | cut -d";" -f1 | trim)
# Jump to next line if this line's host does not match host of ARG1 (if given)
if [[ "${ARG1}" != "" ]] && [[ "${ARG1}" != "${RHOST}" ]]; then
continue
fi
# Task ssh-checker.sh to check this host
if ! "${CURDIR}"/ssh-checker.sh "${RHOST}"; then
logecho "${RHOST}: ERROR when connecting via SSH. Please run ssh-checker.sh to debug."
logecho "${RHOST}: Aborting backup after an error."
continue
fi
RUSER=$(echo "$RHOST" | cut -d"@" -f1)
ALLRDIR=$(echo "$line" | cut -d";" -f2 | trim)
US_VERSION=$(echo "$line" | cut -d";" -f3 | trim)
@@ -65,13 +79,6 @@ while read -r line; do
logecho "${RHOST}: Starting backups"
# Task ssh-checker.sh to check this host
if ! "${CURDIR}"/ssh-checker.sh "${RHOST}"; then
logecho "${RHOST}: ERROR when connecting via SSH. Please run ssh-checker.sh to debug."
logecho "${RHOST}: Aborting backup after an error."
continue
fi
NORDIR=$(echo "$ALLRDIR" | grep -o "|" | wc -l)
NORDIR=$(($NORDIR + 1))