mirror of
https://github.com/deajan/obackup.git
synced 2024-11-14 19:53:42 +01:00
Make sure all files are quoted
This commit is contained in:
parent
7c51784aa1
commit
8210fe9e7f
110
dev/n_obackup.sh
110
dev/n_obackup.sh
@ -7,7 +7,7 @@ PROGRAM="obackup"
|
||||
AUTHOR="(C) 2013-2019 by Orsiris de Jong"
|
||||
CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr"
|
||||
PROGRAM_VERSION=2.1-dev-postRC1
|
||||
PROGRAM_BUILD=2020031501
|
||||
PROGRAM_BUILD=2020050301
|
||||
IS_STABLE=true
|
||||
|
||||
CONFIG_FILE_REVISION_REQUIRED=2.1
|
||||
@ -287,7 +287,7 @@ function _ListDatabasesLocal {
|
||||
Logger "Listing databases failed." "ERROR"
|
||||
_LOGGER_SILENT=true Logger "Command was [$sqlCmd]." "WARN"
|
||||
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" ]; then
|
||||
Logger "Truncated output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
||||
Logger "Truncated output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||
fi
|
||||
return 1
|
||||
fi
|
||||
@ -313,7 +313,7 @@ function _ListDatabasesRemote {
|
||||
Logger "Listing databases failed." "ERROR"
|
||||
Logger "Command output: $sqlCmd" "WARN"
|
||||
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" ]; then
|
||||
Logger "Truncated output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
||||
Logger "Truncated output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||
fi
|
||||
return $retval
|
||||
fi
|
||||
@ -430,11 +430,11 @@ function _ListRecursiveBackupDirectoriesLocal {
|
||||
if [ $retval -ne 0 ]; then
|
||||
Logger "Could not enumerate directories in [$directory]." "ERROR"
|
||||
_LOGGER_SILENT=true Logger "Command was [$cmd]." "WARN"
|
||||
if [ -f $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP ]; then
|
||||
Logger "Truncated output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
||||
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" ]; then
|
||||
Logger "Truncated output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||
fi
|
||||
if [ -f $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP ]; then
|
||||
Logger "Truncated error output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
||||
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP" ]; then
|
||||
Logger "Truncated error output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||
fi
|
||||
failuresPresent=true
|
||||
else
|
||||
@ -502,11 +502,11 @@ exit $?
|
||||
ENDSSH
|
||||
retval=$?
|
||||
if [ $retval -ne 0 ]; then
|
||||
if [ -f $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP ]; then
|
||||
Logger "Truncated output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
||||
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" ]; then
|
||||
Logger "Truncated output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||
fi
|
||||
if [ -f $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP ]; then
|
||||
Logger "Truncated error output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
||||
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP" ]; then
|
||||
Logger "Truncated error output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||
fi
|
||||
fi
|
||||
return $retval
|
||||
@ -606,19 +606,19 @@ function _GetDirectoriesSizeLocal {
|
||||
Logger "Could not get files size for some or all local directories." "ERROR"
|
||||
_LOGGER_SILENT=true Logger "Command was [$cmd]." "WARN"
|
||||
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" ]; then
|
||||
Logger "Truncated output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
||||
Logger "Truncated output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||
fi
|
||||
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP" ]; then
|
||||
Logger "Truncated error output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
||||
Logger "Truncated error output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||
fi
|
||||
else
|
||||
Logger "File size fetched successfully." "NOTICE"
|
||||
fi
|
||||
|
||||
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" ]; then
|
||||
TOTAL_FILES_SIZE="$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)"
|
||||
if [ $(IsInteger $TOTAL_FILES_SIZE) -eq 0 ]; then
|
||||
TOTAL_FILES_SIZE="$(HumanToNumeric $TOTAL_FILES_SIZE)"
|
||||
TOTAL_FILES_SIZE="$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")"
|
||||
if [ $(IsInteger "$TOTAL_FILES_SIZE") -eq 0 ]; then
|
||||
TOTAL_FILES_SIZE="$(HumanToNumeric "$TOTAL_FILES_SIZE")"
|
||||
fi
|
||||
else
|
||||
TOTAL_FILES_SIZE=-1
|
||||
@ -657,18 +657,18 @@ ENDSSH
|
||||
if [ $retval -ne 0 ] || [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP" ]; then
|
||||
Logger "Could not get files size for some or all remote directories." "ERROR"
|
||||
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" ]; then
|
||||
Logger "Truncated output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
||||
Logger "Truncated output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||
fi
|
||||
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP" ]; then
|
||||
Logger "Truncated error output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
||||
Logger "Truncated error output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||
fi
|
||||
else
|
||||
Logger "File size fetched successfully." "NOTICE"
|
||||
fi
|
||||
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" ]; then
|
||||
TOTAL_FILES_SIZE="$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)"
|
||||
if [ $(IsInteger $TOTAL_FILES_SIZE) -eq 0 ]; then
|
||||
TOTAL_FILES_SIZE="$(HumanToNumeric $TOTAL_FILES_SIZE)"
|
||||
TOTAL_FILES_SIZE="$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")"
|
||||
if [ $(IsInteger "$TOTAL_FILES_SIZE") -eq 0 ]; then
|
||||
TOTAL_FILES_SIZE="$(HumanToNumeric "$TOTAL_FILES_SIZE")"
|
||||
fi
|
||||
else
|
||||
TOTAL_FILES_SIZE=-1
|
||||
@ -699,13 +699,13 @@ function _CreateDirectoryLocal {
|
||||
|
||||
if [ ! -d "$dirToCreate" ]; then
|
||||
# No sudo, you should have all necessary rights
|
||||
mkdir -p "$dirToCreate" > $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP 2>&1 &
|
||||
mkdir -p "$dirToCreate" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" 2>&1 &
|
||||
ExecTasks $! "${FUNCNAME[0]}" false 0 0 720 1800 true $SLEEP_TIME $KEEP_LOGGING
|
||||
retval=$?
|
||||
if [ $retval -ne 0 ]; then
|
||||
Logger "Cannot create directory [$dirToCreate]" "CRITICAL"
|
||||
if [ -f $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP ]; then
|
||||
Logger "Truncated output: $(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
||||
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" ]; then
|
||||
Logger "Truncated output: $(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||
fi
|
||||
return $retval
|
||||
fi
|
||||
@ -745,7 +745,7 @@ ENDSSH
|
||||
ExecTasks $! "${FUNCNAME[0]}" false 0 0 720 1800 true $SLEEP_TIME $KEEP_LOGGING
|
||||
retval=$?
|
||||
if [ $retval -ne 0 ]; then
|
||||
Logger "Truncated output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
||||
Logger "Truncated output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||
return $retval
|
||||
fi
|
||||
}
|
||||
@ -812,12 +812,12 @@ function GetDiskSpaceLocal {
|
||||
if [ $retval -ne 0 ]; then
|
||||
DISK_SPACE=0
|
||||
Logger "Cannot get disk space in [$pathToCheck] on local system." "ERROR"
|
||||
Logger "Truncated output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
||||
Logger "Truncated output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||
else
|
||||
DISK_SPACE=$(tail -1 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" | awk '{print $4}')
|
||||
DRIVE=$(tail -1 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" | awk '{print $1}')
|
||||
if [ $(IsInteger $DISK_SPACE) -eq 0 ]; then
|
||||
DISK_SPACE="$(HumanToNumeric $DISK_SPACE)"
|
||||
if [ $(IsInteger "$DISK_SPACE") -eq 0 ]; then
|
||||
DISK_SPACE="$(HumanToNumeric "$DISK_SPACE")"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
@ -872,14 +872,14 @@ ENDSSH
|
||||
if [ $retval -ne 0 ]; then
|
||||
DISK_SPACE=0
|
||||
Logger "Cannot get disk space in [$pathToCheck] on remote system." "ERROR"
|
||||
Logger "Truncated output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
||||
Logger "Truncated output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
||||
Logger "Truncated output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||
Logger "Truncated output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||
return $retval
|
||||
else
|
||||
DISK_SPACE=$(tail -1 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" | awk '{print $4}')
|
||||
DRIVE=$(tail -1 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" | awk '{print $1}')
|
||||
if [ $(IsInteger $DISK_SPACE) -eq 0 ]; then
|
||||
DISK_SPACE="$(HumanToNumeric $DISK_SPACE)"
|
||||
if [ $(IsInteger "$DISK_SPACE") -eq 0 ]; then
|
||||
DISK_SPACE="$(HumanToNumeric "$DISK_SPACE")"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -1055,7 +1055,7 @@ function _BackupDatabaseLocalToLocal {
|
||||
else
|
||||
_LOGGER_SILENT=true Logger "Command was [$drySqlCmd]." "WARN"
|
||||
fi
|
||||
Logger "Truncated error output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
||||
Logger "Truncated error output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||
# Dirty fix for mysqldump return code not honored
|
||||
retval=1
|
||||
fi
|
||||
@ -1102,7 +1102,7 @@ function _BackupDatabaseLocalToRemote {
|
||||
else
|
||||
_LOGGER_SILENT=true Logger "Command was [$drySqlCmd]." "WARN"
|
||||
fi
|
||||
Logger "Truncated error output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
||||
Logger "Truncated error output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||
# Dirty fix for mysqldump return code not honored
|
||||
retval=1
|
||||
fi
|
||||
@ -1149,7 +1149,7 @@ function _BackupDatabaseRemoteToLocal {
|
||||
else
|
||||
_LOGGER_SILENT=true Logger "Command was [$drySqlCmd]." "WARN"
|
||||
fi
|
||||
Logger "Truncated error output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
||||
Logger "Truncated error output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||
# Dirty fix for mysqldump return code not honored
|
||||
retval=1
|
||||
fi
|
||||
@ -1255,13 +1255,13 @@ function EncryptFiles {
|
||||
fi
|
||||
|
||||
Logger "Encrypting file [$sourceFile] to [$path/$file$cryptFileExtension]." "VERBOSE"
|
||||
if [ $(IsNumeric $PARALLEL_ENCRYPTION_PROCESSES) -eq 1 ] && [ "$PARALLEL_ENCRYPTION_PROCESSES" != "1" ]; then
|
||||
if [ $(IsNumeric "$PARALLEL_ENCRYPTION_PROCESSES") -eq 1 ] && [ "$PARALLEL_ENCRYPTION_PROCESSES" != "1" ]; then
|
||||
echo "$CRYPT_TOOL --batch --yes --out \"$path/$file$cryptFileExtension\" --recipient=\"$recipient\" --encrypt \"$sourceFile\" >> \"$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP\" 2>&1" >> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.parallel.$SCRIPT_PID.$TSTAMP"
|
||||
else
|
||||
$CRYPT_TOOL --batch --yes --out "$path/$file$cryptFileExtension" --recipient="$recipient" --encrypt "$sourceFile" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
Logger "Cannot encrypt [$sourceFile]." "ERROR"
|
||||
Logger "Truncated output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "DEBUG"
|
||||
Logger "Truncated output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "DEBUG"
|
||||
errorCounter=$((errorCounter+1))
|
||||
else
|
||||
successCounter=$((successCounter+1))
|
||||
@ -1270,16 +1270,16 @@ function EncryptFiles {
|
||||
#TODO: This redirection does not work with busybox since there is no subshell support
|
||||
done < <($FIND_CMD "$filePath" $recursiveArgs -type f ! -name "*$cryptFileExtension" -print0)
|
||||
|
||||
if [ $(IsNumeric $PARALLEL_ENCRYPTION_PROCESSES) -eq 1 ] && [ "$PARALLEL_ENCRYPTION_PROCESSES" != "1" ]; then
|
||||
if [ $(IsNumeric "$PARALLEL_ENCRYPTION_PROCESSES") -eq 1 ] && [ "$PARALLEL_ENCRYPTION_PROCESSES" != "1" ]; then
|
||||
# Handle batch mode where SOFT /HARD MAX EXEC TIME TOTAL is not defined
|
||||
if [ $(IsNumeric $SOFT_MAX_EXEC_TIME_TOTAL) -eq 1 ]; then
|
||||
softMaxExecTime=$SOFT_MAX_EXEC_TIME_TOTAL
|
||||
if [ $(IsNumeric "$SOFT_MAX_EXEC_TIME_TOTAL") -eq 1 ]; then
|
||||
softMaxExecTime="$SOFT_MAX_EXEC_TIME_TOTAL"
|
||||
else
|
||||
softMaxExecTime=0
|
||||
fi
|
||||
|
||||
if [ $(IsNumeric $HARD_MAX_EXEC_TIME_TOTAL) -eq 1 ]; then
|
||||
hardMaxExecTime=$HARD_MAX_EXEC_TIME_TOTAL
|
||||
if [ $(IsNumeric "$HARD_MAX_EXEC_TIME_TOTAL") -eq 1 ]; then
|
||||
hardMaxExecTime="$HARD_MAX_EXEC_TIME_TOTAL"
|
||||
else
|
||||
hardMaxExecTime=0
|
||||
fi
|
||||
@ -1288,7 +1288,7 @@ function EncryptFiles {
|
||||
if [ $retval -ne 0 ]; then
|
||||
Logger "Encryption error." "ERROR"
|
||||
# Output file is defined in ParallelExec
|
||||
Logger "Truncated output:\n$(head -c16384 $RUN_DIR/$PROGRAM.ExecTasks.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "DEBUG"
|
||||
Logger "Truncated output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.ExecTasks.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "DEBUG"
|
||||
fi
|
||||
successCounter=$(($(wc -l < "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.parallel.$SCRIPT_PID.$TSTAMP") - retval))
|
||||
errorCounter=$retval
|
||||
@ -1329,7 +1329,7 @@ function DecryptFiles {
|
||||
fi
|
||||
|
||||
# Detect if GnuPG >= 2.1 that does not allow automatic pin entry anymore
|
||||
cryptToolVersion=$($CRYPT_TOOL --version | head -1 | awk '{print $3}')
|
||||
cryptToolVersion=$("$CRYPT_TOOL" --version | head -1 | awk '{print $3}')
|
||||
cryptToolMajorVersion=${cryptToolVersion%%.*}
|
||||
cryptToolSubVersion=${cryptToolVersion#*.}
|
||||
cryptToolSubVersion=${cryptToolSubVersion%.*}
|
||||
@ -1356,14 +1356,14 @@ function DecryptFiles {
|
||||
while IFS= read -r -d $'\0' encryptedFile; do
|
||||
Logger "Decrypting [$encryptedFile]." "VERBOSE"
|
||||
|
||||
if [ $(IsNumeric $PARALLEL_ENCRYPTION_PROCESSES) -eq 1 ] && [ "$PARALLEL_ENCRYPTION_PROCESSES" != "1" ]; then
|
||||
if [ $(IsNumeric "$PARALLEL_ENCRYPTION_PROCESSES") -eq 1 ] && [ "$PARALLEL_ENCRYPTION_PROCESSES" != "1" ]; then
|
||||
echo "$CRYPT_TOOL $options --out \"${encryptedFile%%$cryptFileExtension}\" $additionalParameters $secret --decrypt \"$encryptedFile\" >> \"$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP\" 2>&1" >> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.parallel.$SCRIPT_PID.$TSTAMP"
|
||||
else
|
||||
$CRYPT_TOOL $options --out "${encryptedFile%%$cryptFileExtension}" $additionalParameters $secret --decrypt "$encryptedFile" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" 2>&1
|
||||
retval=$?
|
||||
if [ $retval -ne 0 ]; then
|
||||
Logger "Cannot decrypt [$encryptedFile]." "ERROR"
|
||||
Logger "Truncated output\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "NOTICE"
|
||||
Logger "Truncated output\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "NOTICE"
|
||||
errorCounter=$((errorCounter+1))
|
||||
else
|
||||
successCounter=$((successCounter+1))
|
||||
@ -1375,15 +1375,15 @@ function DecryptFiles {
|
||||
fi
|
||||
done < <($FIND_CMD "$filePath" -type f -name "*$cryptFileExtension" -print0)
|
||||
|
||||
if [ $(IsNumeric $PARALLEL_ENCRYPTION_PROCESSES) -eq 1 ] && [ "$PARALLEL_ENCRYPTION_PROCESSES" != "1" ]; then
|
||||
if [ $(IsNumeric "$PARALLEL_ENCRYPTION_PROCESSES") -eq 1 ] && [ "$PARALLEL_ENCRYPTION_PROCESSES" != "1" ]; then
|
||||
# Handle batch mode where SOFT /HARD MAX EXEC TIME TOTAL is not defined
|
||||
if [ $(IsNumeric $SOFT_MAX_EXEC_TIME_TOTAL) -eq 1 ]; then
|
||||
if [ $(IsNumeric "$SOFT_MAX_EXEC_TIME_TOTAL") -eq 1 ]; then
|
||||
softMaxExecTime=$SOFT_MAX_EXEC_TIME_TOTAL
|
||||
else
|
||||
softMaxExecTime=0
|
||||
fi
|
||||
|
||||
if [ $(IsNumeric $HARD_MAX_EXEC_TIME_TOTAL) -eq 1 ]; then
|
||||
if [ $(IsNumeric "$HARD_MAX_EXEC_TIME_TOTAL") -eq 1 ]; then
|
||||
hardMaxExecTime=$HARD_MAX_EXEC_TIME_TOTAL
|
||||
else
|
||||
hardMaxExecTime=0
|
||||
@ -1394,7 +1394,7 @@ function DecryptFiles {
|
||||
if [ $retval -ne 0 ]; then
|
||||
Logger "Decrypting error.." "ERROR"
|
||||
# Output file is defined in ParallelExec
|
||||
Logger "Truncated output:\n$(head -c16384 $RUN_DIR/$PROGRAM.ParallelExec.EncryptFiles.$SCRIPT_PID.$TSTAMP)" "DEBUG"
|
||||
Logger "Truncated output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.ParallelExec.EncryptFiles.$SCRIPT_PID.$TSTAMP")" "DEBUG"
|
||||
fi
|
||||
successCounter=$(($(wc -l < "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.parallel.$SCRIPT_PID.$TSTAMP") - retval))
|
||||
errorCounter=$retval
|
||||
@ -1457,7 +1457,7 @@ function Rsync {
|
||||
if [ $retval -ne 0 ]; then
|
||||
Logger "Failed to backup [$sourceDir] to [$destinationDir]." "ERROR"
|
||||
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN"
|
||||
Logger "Truncated output:\n $(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
||||
Logger "Truncated output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||
else
|
||||
Logger "Truncated output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "VERBOSE"
|
||||
Logger "File backup succeed." "NOTICE"
|
||||
@ -1767,7 +1767,7 @@ ENDSSH
|
||||
ExecTasks $! "${FUNCNAME[0]}" false 0 0 1800 0 true $SLEEP_TIME $KEEP_LOGGING
|
||||
if [ $? -ne 0 ]; then
|
||||
Logger "Could not rotate backups in [$backupPath]." "ERROR"
|
||||
Logger "Truncated output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
||||
Logger "Truncated output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||
else
|
||||
Logger "Remote rotation succeed." "NOTICE"
|
||||
fi ## Need to add a trivial sleep time to give ssh time to log to local file
|
||||
@ -2010,7 +2010,7 @@ function GetCommandlineArguments {
|
||||
;;
|
||||
--parallel=*)
|
||||
PARALLEL_ENCRYPTION_PROCESSES="${i##*=}"
|
||||
if [ $(IsNumeric $PARALLEL_ENCRYPTION_PROCESSES) -ne 1 ]; then
|
||||
if [ $(IsNumeric "$PARALLEL_ENCRYPTION_PROCESSES") -ne 1 ]; then
|
||||
Logger "Bogus --parallel value. Using only one CPU." "WARN"
|
||||
fi
|
||||
;;
|
||||
@ -2065,8 +2065,8 @@ fi
|
||||
# v2.3 config syntax compatibility
|
||||
UpdateBooleans
|
||||
|
||||
if [ ! -w "$(dirname $LOG_FILE)" ]; then
|
||||
echo "Cannot write to log [$(dirname $LOG_FILE)]."
|
||||
if [ ! -w "$(dirname "$LOG_FILE")" ]; then
|
||||
echo "Cannot write to log [$(dirname "$LOG_FILE")]."
|
||||
else
|
||||
Logger "Script begin, logging to [$LOG_FILE]." "DEBUG"
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user