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