mirror of
https://github.com/deajan/obackup.git
synced 2024-11-15 04:03:41 +01:00
Rebuilt targets
This commit is contained in:
parent
42684fbdf8
commit
233ec565e3
File diff suppressed because it is too large
Load Diff
116
install.sh
116
install.sh
@ -10,7 +10,7 @@ PROGRAM_BINARY=$PROGRAM".sh"
|
|||||||
PROGRAM_BATCH=$PROGRAM"-batch.sh"
|
PROGRAM_BATCH=$PROGRAM"-batch.sh"
|
||||||
SSH_FILTER="ssh_filter.sh"
|
SSH_FILTER="ssh_filter.sh"
|
||||||
|
|
||||||
SCRIPT_BUILD=2018100206
|
SCRIPT_BUILD=2019022601
|
||||||
INSTANCE_ID="installer-$SCRIPT_BUILD"
|
INSTANCE_ID="installer-$SCRIPT_BUILD"
|
||||||
|
|
||||||
## osync / obackup / pmocr / zsnap install script
|
## osync / obackup / pmocr / zsnap install script
|
||||||
@ -18,7 +18,7 @@ INSTANCE_ID="installer-$SCRIPT_BUILD"
|
|||||||
## Please adapt this to fit your distro needs
|
## Please adapt this to fit your distro needs
|
||||||
|
|
||||||
_OFUNCTIONS_VERSION=2.3.0-RC2
|
_OFUNCTIONS_VERSION=2.3.0-RC2
|
||||||
_OFUNCTIONS_BUILD=2018122103
|
_OFUNCTIONS_BUILD=2019012801
|
||||||
_OFUNCTIONS_BOOTSTRAP=true
|
_OFUNCTIONS_BOOTSTRAP=true
|
||||||
|
|
||||||
if ! type "$BASH" > /dev/null; then
|
if ! type "$BASH" > /dev/null; then
|
||||||
@ -50,9 +50,9 @@ ERROR_ALERT=false
|
|||||||
WARN_ALERT=false
|
WARN_ALERT=false
|
||||||
|
|
||||||
|
|
||||||
## allow debugging from command line with _DEBUG=yes
|
## allow debugging from command line with _DEBUG=true
|
||||||
if [ ! "$_DEBUG" == "yes" ]; then
|
if [ ! "$_DEBUG" == true ]; then
|
||||||
_DEBUG=no
|
_DEBUG=false
|
||||||
_LOGGER_VERBOSE=false
|
_LOGGER_VERBOSE=false
|
||||||
else
|
else
|
||||||
trap 'TrapError ${LINENO} $?' ERR
|
trap 'TrapError ${LINENO} $?' ERR
|
||||||
@ -83,7 +83,6 @@ else
|
|||||||
LOG_FILE="/tmp/$PROGRAM.log"
|
LOG_FILE="/tmp/$PROGRAM.log"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#### RUN_DIR SUBSET ####
|
|
||||||
## Default directory where to store temporary run files
|
## Default directory where to store temporary run files
|
||||||
|
|
||||||
if [ -w /tmp ]; then
|
if [ -w /tmp ]; then
|
||||||
@ -99,7 +98,6 @@ if [ "$_REMOTE_EXECUTION" == true ]; then
|
|||||||
mkdir -p "$RUN_DIR/$PROGRAM.remote"
|
mkdir -p "$RUN_DIR/$PROGRAM.remote"
|
||||||
RUN_DIR="$RUN_DIR/$PROGRAM.remote"
|
RUN_DIR="$RUN_DIR/$PROGRAM.remote"
|
||||||
fi
|
fi
|
||||||
#### RUN_DIR SUBSET END ####
|
|
||||||
|
|
||||||
# Get a random number on Windows BusyBox alike, also works on most Unixes that have dd, if dd is not found, then return $RANDOM
|
# Get a random number on Windows BusyBox alike, also works on most Unixes that have dd, if dd is not found, then return $RANDOM
|
||||||
function PoorMansRandomGenerator {
|
function PoorMansRandomGenerator {
|
||||||
@ -201,19 +199,19 @@ function RemoteLogger {
|
|||||||
|
|
||||||
if [ "$level" == "CRITICAL" ]; then
|
if [ "$level" == "CRITICAL" ]; then
|
||||||
_Logger "" "$prefix\e[1;33;41m$value\e[0m" true
|
_Logger "" "$prefix\e[1;33;41m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
elif [ "$level" == "ERROR" ]; then
|
elif [ "$level" == "ERROR" ]; then
|
||||||
_Logger "" "$prefix\e[31m$value\e[0m" true
|
_Logger "" "$prefix\e[31m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
elif [ "$level" == "WARN" ]; then
|
elif [ "$level" == "WARN" ]; then
|
||||||
_Logger "" "$prefix\e[33m$value\e[0m" true
|
_Logger "" "$prefix\e[33m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
@ -231,7 +229,7 @@ function RemoteLogger {
|
|||||||
_Logger "" "$prefix$value"
|
_Logger "" "$prefix$value"
|
||||||
return
|
return
|
||||||
elif [ "$level" == "DEBUG" ]; then
|
elif [ "$level" == "DEBUG" ]; then
|
||||||
if [ "$_DEBUG" == "yes" ]; then
|
if [ "$_DEBUG" == true ]; then
|
||||||
_Logger "" "$prefix$value"
|
_Logger "" "$prefix$value"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -255,8 +253,7 @@ function RemoteLogger {
|
|||||||
# NOTICE sent to stdout
|
# NOTICE sent to stdout
|
||||||
# VERBOSE sent to stdout if _LOGGER_VERBOSE=true
|
# VERBOSE sent to stdout if _LOGGER_VERBOSE=true
|
||||||
# ALWAYS is sent to stdout unless _LOGGER_SILENT=true
|
# ALWAYS is sent to stdout unless _LOGGER_SILENT=true
|
||||||
# DEBUG & PARANOIA_DEBUG are only sent to stdout if _DEBUG=yes
|
# DEBUG & PARANOIA_DEBUG are only sent to stdout if _DEBUG=true
|
||||||
# SIMPLE is a wrapper for QuickLogger that does not use advanced functionality
|
|
||||||
function Logger {
|
function Logger {
|
||||||
local value="${1}" # Sentence to log (in double quotes)
|
local value="${1}" # Sentence to log (in double quotes)
|
||||||
local level="${2}" # Log level
|
local level="${2}" # Log level
|
||||||
@ -306,17 +303,10 @@ function Logger {
|
|||||||
_Logger "$prefix$value" "$prefix$value"
|
_Logger "$prefix$value" "$prefix$value"
|
||||||
return
|
return
|
||||||
elif [ "$level" == "DEBUG" ]; then
|
elif [ "$level" == "DEBUG" ]; then
|
||||||
if [ "$_DEBUG" == "yes" ]; then
|
if [ "$_DEBUG" == true ]; then
|
||||||
_Logger "$prefix$value" "$prefix$value"
|
_Logger "$prefix$value" "$prefix$value"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
elif [ "$level" == "SIMPLE" ]; then
|
|
||||||
if [ "$_LOGGER_SILENT" == true ]; then
|
|
||||||
_Logger "$preix$value"
|
|
||||||
else
|
|
||||||
_Logger "$preix$value" "$prefix$value"
|
|
||||||
fi
|
|
||||||
return
|
|
||||||
else
|
else
|
||||||
_Logger "\e[41mLogger function called without proper loglevel [$level].\e[0m" "\e[41mLogger function called without proper loglevel [$level].\e[0m" true
|
_Logger "\e[41mLogger function called without proper loglevel [$level].\e[0m" "\e[41mLogger function called without proper loglevel [$level].\e[0m" true
|
||||||
_Logger "Value was: $prefix$value" "Value was: $prefix$value" true
|
_Logger "Value was: $prefix$value" "Value was: $prefix$value" true
|
||||||
@ -409,7 +399,7 @@ function KillAllChilds {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function CleanUp {
|
function CleanUp {
|
||||||
if [ "$_DEBUG" != "yes" ]; then
|
if [ "$_DEBUG" != true ]; then
|
||||||
rm -f "$RUN_DIR/$PROGRAM."*".$SCRIPT_PID.$TSTAMP"
|
rm -f "$RUN_DIR/$PROGRAM."*".$SCRIPT_PID.$TSTAMP"
|
||||||
# Fix for sed -i requiring backup extension for BSD & Mac (see all sed -i statements)
|
# Fix for sed -i requiring backup extension for BSD & Mac (see all sed -i statements)
|
||||||
rm -f "$RUN_DIR/$PROGRAM."*".$SCRIPT_PID.$TSTAMP.tmp"
|
rm -f "$RUN_DIR/$PROGRAM."*".$SCRIPT_PID.$TSTAMP.tmp"
|
||||||
@ -462,7 +452,7 @@ function GetCommandlineArguments {
|
|||||||
Usage
|
Usage
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
Logger "Unknown option '$i'" "SIMPLE"
|
Logger "Unknown option '$i'" "ERROR"
|
||||||
Usage
|
Usage
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
@ -573,7 +563,7 @@ function GetLocalOS {
|
|||||||
LOCAL_OS="BusyBox"
|
LOCAL_OS="BusyBox"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if [ "$IGNORE_OS_TYPE" == "yes" ]; then
|
if [ "$IGNORE_OS_TYPE" == true ]; then
|
||||||
Logger "Running on unknown local OS [$localOsVar]." "WARN"
|
Logger "Running on unknown local OS [$localOsVar]." "WARN"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -668,12 +658,12 @@ function SetLocalOSSettings {
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
if [ "$LOCAL_OS" == "Android" ] || [ "$LOCAL_OS" == "BusyBox" ]; then
|
if [ "$LOCAL_OS" == "Android" ] || [ "$LOCAL_OS" == "BusyBox" ]; then
|
||||||
Logger "Cannot be installed on [$LOCAL_OS]. Please use $PROGRAM.sh directly." "SIMPLE"
|
Logger "Cannot be installed on [$LOCAL_OS]. Please use $PROGRAM.sh directly." "CRITICAL"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ([ "$USER" != "" ] && [ "$(whoami)" != "$USER" ] && [ "$FAKEROOT" == "" ]); then
|
if ([ "$USER" != "" ] && [ "$(whoami)" != "$USER" ] && [ "$FAKEROOT" == "" ]); then
|
||||||
Logger "Must be run as $USER." "SIMPLE"
|
Logger "Must be run as $USER." "CRITICAL"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -683,17 +673,17 @@ function SetLocalOSSettings {
|
|||||||
function GetInit {
|
function GetInit {
|
||||||
if [ -f /sbin/openrc-run ]; then
|
if [ -f /sbin/openrc-run ]; then
|
||||||
init="openrc"
|
init="openrc"
|
||||||
Logger "Detected openrc." "SIMPLE"
|
Logger "Detected openrc." "NOTICE"
|
||||||
elif [ -f /sbin/init ]; then
|
elif [ -f /sbin/init ]; then
|
||||||
if file /sbin/init | grep systemd > /dev/null; then
|
if file /sbin/init | grep systemd > /dev/null; then
|
||||||
init="systemd"
|
init="systemd"
|
||||||
Logger "Detected systemd." "SIMPLE"
|
Logger "Detected systemd." "NOTICE"
|
||||||
else
|
else
|
||||||
init="initV"
|
init="initV"
|
||||||
Logger "Detected initV." "SIMPLE"
|
Logger "Detected initV." "NOTICE"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
Logger "Can't detect initV, systemd or openRC. Service files won't be installed. You can still run $PROGRAM manually or via cron." "SIMPLE"
|
Logger "Can't detect initV, systemd or openRC. Service files won't be installed. You can still run $PROGRAM manually or via cron." "WARN"
|
||||||
init="none"
|
init="none"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -712,9 +702,9 @@ function CreateDir {
|
|||||||
mkdir -p "$dir"
|
mkdir -p "$dir"
|
||||||
)
|
)
|
||||||
if [ $? == 0 ]; then
|
if [ $? == 0 ]; then
|
||||||
Logger "Created directory [$dir]." "SIMPLE"
|
Logger "Created directory [$dir]." "NOTICE"
|
||||||
else
|
else
|
||||||
Logger "Cannot create directory [$dir]." "SIMPLE"
|
Logger "Cannot create directory [$dir]." "CRITICAL"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -726,10 +716,10 @@ function CreateDir {
|
|||||||
fi
|
fi
|
||||||
chown "$userGroup" "$dir"
|
chown "$userGroup" "$dir"
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Could not set directory ownership on [$dir] to [$userGroup]." "SIMPLE"
|
Logger "Could not set directory ownership on [$dir] to [$userGroup]." "CRITICAL"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
Logger "Set file ownership on [$dir] to [$userGroup]." "SIMPLE"
|
Logger "Set file ownership on [$dir] to [$userGroup]." "NOTICE"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -753,26 +743,26 @@ function CopyFile {
|
|||||||
|
|
||||||
if [ -f "$destPath/$destFileName" ] && [ $overwrite == false ]; then
|
if [ -f "$destPath/$destFileName" ] && [ $overwrite == false ]; then
|
||||||
destfileName="$sourceFileName.new"
|
destfileName="$sourceFileName.new"
|
||||||
Logger "Copying [$sourceFileName] to [$destPath/$destFilename]." "SIMPLE"
|
Logger "Copying [$sourceFileName] to [$destPath/$destFilename]." "NOTICE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp "$sourcePath/$sourceFileName" "$destPath/$destFileName"
|
cp "$sourcePath/$sourceFileName" "$destPath/$destFileName"
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot copy [$sourcePath/$sourceFileName] to [$destPath/$destFileName]. Make sure to run install script in the directory containing all other files." "SIMPLE"
|
Logger "Cannot copy [$sourcePath/$sourceFileName] to [$destPath/$destFileName]. Make sure to run install script in the directory containing all other files." "CRITICAL"
|
||||||
Logger "Also make sure you have permissions to write to [$BIN_DIR]." "SIMPLE"
|
Logger "Also make sure you have permissions to write to [$BIN_DIR]." "ERROR"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
Logger "Copied [$sourcePath/$sourceFileName] to [$destPath/$destFileName]." "SIMPLE"
|
Logger "Copied [$sourcePath/$sourceFileName] to [$destPath/$destFileName]." "NOTICE"
|
||||||
if [ "$(IsInteger $fileMod)" -eq 1 ]; then
|
if [ "$(IsInteger $fileMod)" -eq 1 ]; then
|
||||||
chmod "$fileMod" "$destPath/$destFileName"
|
chmod "$fileMod" "$destPath/$destFileName"
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot set file permissions of [$destPath/$destFileName] to [$fileMod]." "SIMPLE"
|
Logger "Cannot set file permissions of [$destPath/$destFileName] to [$fileMod]." "CRITICAL"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
Logger "Set file permissions to [$fileMod] on [$destPath/$destFileName]." "SIMPLE"
|
Logger "Set file permissions to [$fileMod] on [$destPath/$destFileName]." "NOTICE"
|
||||||
fi
|
fi
|
||||||
elif [ "$fileMod" != "" ]; then
|
elif [ "$fileMod" != "" ]; then
|
||||||
Logger "Bogus filemod [$fileMod] for [$destPath] given." "SIMPLE"
|
Logger "Bogus filemod [$fileMod] for [$destPath] given." "WARN"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$fileUser" != "" ]; then
|
if [ "$fileUser" != "" ]; then
|
||||||
@ -784,10 +774,10 @@ function CopyFile {
|
|||||||
|
|
||||||
chown "$userGroup" "$destPath/$destFileName"
|
chown "$userGroup" "$destPath/$destFileName"
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Could not set file ownership on [$destPath/$destFileName] to [$userGroup]." "SIMPLE"
|
Logger "Could not set file ownership on [$destPath/$destFileName] to [$userGroup]." "CRITICAL"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
Logger "Set file ownership on [$destPath/$destFileName] to [$userGroup]." "SIMPLE"
|
Logger "Set file ownership on [$destPath/$destFileName] to [$userGroup]." "NOTICE"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -839,25 +829,25 @@ function CopyServiceFiles {
|
|||||||
CreateDir "$SERVICE_DIR_SYSTEMD_USER"
|
CreateDir "$SERVICE_DIR_SYSTEMD_USER"
|
||||||
CopyFile "$SCRIPT_PATH" "$SERVICE_DIR_SYSTEMD_USER" "$SERVICE_FILE_SYSTEMD_USER" "$SERVICE_FILE_SYSTEMD_USER" "" "" "" true
|
CopyFile "$SCRIPT_PATH" "$SERVICE_DIR_SYSTEMD_USER" "$SERVICE_FILE_SYSTEMD_USER" "$SERVICE_FILE_SYSTEMD_USER" "" "" "" true
|
||||||
fi
|
fi
|
||||||
Logger "Created [$SERVICE_NAME] service in [$SERVICE_DIR_SYSTEMD_SYSTEM] and [$SERVICE_DIR_SYSTEMD_USER]." "SIMPLE"
|
Logger "Created [$SERVICE_NAME] service in [$SERVICE_DIR_SYSTEMD_SYSTEM] and [$SERVICE_DIR_SYSTEMD_USER]." "NOTICE"
|
||||||
Logger "Can be activated with [systemctl start SERVICE_NAME@instance.conf] where instance.conf is the name of the config file in $CONF_DIR." "SIMPLE"
|
Logger "Can be activated with [systemctl start SERVICE_NAME@instance.conf] where instance.conf is the name of the config file in $CONF_DIR." "NOTICE"
|
||||||
Logger "Can be enabled on boot with [systemctl enable $SERVICE_NAME@instance.conf]." "SIMPLE"
|
Logger "Can be enabled on boot with [systemctl enable $SERVICE_NAME@instance.conf]." "NOTICE"
|
||||||
Logger "In userland, active with [systemctl --user start $SERVICE_NAME@instance.conf]." "SIMPLE"
|
Logger "In userland, active with [systemctl --user start $SERVICE_NAME@instance.conf]." "NOTICE"
|
||||||
elif ([ "$init" == "initV" ] && [ -f "$SCRIPT_PATH/$SERVICE_FILE_INIT" ] && [ -d "$SERVICE_DIR_INIT" ]); then
|
elif ([ "$init" == "initV" ] && [ -f "$SCRIPT_PATH/$SERVICE_FILE_INIT" ] && [ -d "$SERVICE_DIR_INIT" ]); then
|
||||||
#CreateDir "$SERVICE_DIR_INIT"
|
#CreateDir "$SERVICE_DIR_INIT"
|
||||||
CopyFile "$SCRIPT_PATH" "$SERVICE_DIR_INIT" "$SERVICE_FILE_INIT" "$SERVICE_FILE_INIT" "755" "" "" true
|
CopyFile "$SCRIPT_PATH" "$SERVICE_DIR_INIT" "$SERVICE_FILE_INIT" "$SERVICE_FILE_INIT" "755" "" "" true
|
||||||
|
|
||||||
Logger "Created [$SERVICE_NAME] service in [$SERVICE_DIR_INIT]." "SIMPLE"
|
Logger "Created [$SERVICE_NAME] service in [$SERVICE_DIR_INIT]." "NOTICE"
|
||||||
Logger "Can be activated with [service $SERVICE_FILE_INIT start]." "SIMPLE"
|
Logger "Can be activated with [service $SERVICE_FILE_INIT start]." "NOTICE"
|
||||||
Logger "Can be enabled on boot with [chkconfig $SERVICE_FILE_INIT on]." "SIMPLE"
|
Logger "Can be enabled on boot with [chkconfig $SERVICE_FILE_INIT on]." "NOTICE"
|
||||||
elif ([ "$init" == "openrc" ] && [ -f "$SCRIPT_PATH/$SERVICE_FILE_OPENRC" ] && [ -d "$SERVICE_DIR_OPENRC" ]); then
|
elif ([ "$init" == "openrc" ] && [ -f "$SCRIPT_PATH/$SERVICE_FILE_OPENRC" ] && [ -d "$SERVICE_DIR_OPENRC" ]); then
|
||||||
# Rename service to usual service file
|
# Rename service to usual service file
|
||||||
CopyFile "$SCRIPT_PATH" "$SERVICE_DIR_OPENRC" "$SERVICE_FILE_OPENRC" "$SERVICE_FILE_INIT" "755" "" "" true
|
CopyFile "$SCRIPT_PATH" "$SERVICE_DIR_OPENRC" "$SERVICE_FILE_OPENRC" "$SERVICE_FILE_INIT" "755" "" "" true
|
||||||
|
|
||||||
Logger "Created [$SERVICE_NAME] service in [$SERVICE_DIR_OPENRC]." "SIMPLE"
|
Logger "Created [$SERVICE_NAME] service in [$SERVICE_DIR_OPENRC]." "NOTICE"
|
||||||
Logger "Can be activated with [rc-update add $SERVICE_NAME.instance] where instance is a configuration file found in /etc/osync." "SIMPLE"
|
Logger "Can be activated with [rc-update add $SERVICE_NAME.instance] where instance is a configuration file found in /etc/osync." "NOTICE"
|
||||||
else
|
else
|
||||||
Logger "Cannot properly find how to deal with init on this system. Skipping service file installation." "SIMPLE"
|
Logger "Cannot properly find how to deal with init on this system. Skipping service file installation." "NOTICE"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -876,7 +866,7 @@ function Statistics {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
Logger "Neiter wget nor curl could be used for. Cannot run statistics. Use the provided link please." "SIMPLE"
|
Logger "Neiter wget nor curl could be used for. Cannot run statistics. Use the provided link please." "WARN"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -886,12 +876,12 @@ function RemoveFile {
|
|||||||
if [ -f "$file" ]; then
|
if [ -f "$file" ]; then
|
||||||
rm -f "$file"
|
rm -f "$file"
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Could not remove file [$file]." "SIMPLE"
|
Logger "Could not remove file [$file]." "ERROR"
|
||||||
else
|
else
|
||||||
Logger "Removed file [$file]." "SIMPLE"
|
Logger "Removed file [$file]." "NOTICE"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
Logger "File [$file] not found. Skipping." "SIMPLE"
|
Logger "File [$file] not found. Skipping." "NOTICE"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -905,13 +895,13 @@ function RemoveAll {
|
|||||||
if [ ! -f "$BIN_DIR/osync.sh" ] && [ ! -f "$BIN_DIR/obackup.sh" ]; then # Check if any other program requiring ssh filter is present before removal
|
if [ ! -f "$BIN_DIR/osync.sh" ] && [ ! -f "$BIN_DIR/obackup.sh" ]; then # Check if any other program requiring ssh filter is present before removal
|
||||||
RemoveFile "$BIN_DIR/$SSH_FILTER"
|
RemoveFile "$BIN_DIR/$SSH_FILTER"
|
||||||
else
|
else
|
||||||
Logger "Skipping removal of [$BIN_DIR/$SSH_FILTER] because other programs present that need it." "SIMPLE"
|
Logger "Skipping removal of [$BIN_DIR/$SSH_FILTER] because other programs present that need it." "NOTICE"
|
||||||
fi
|
fi
|
||||||
RemoveFile "$SERVICE_DIR_SYSTEMD_SYSTEM/$SERVICE_FILE_SYSTEMD_SYSTEM"
|
RemoveFile "$SERVICE_DIR_SYSTEMD_SYSTEM/$SERVICE_FILE_SYSTEMD_SYSTEM"
|
||||||
RemoveFile "$SERVICE_DIR_SYSTEMD_USER/$SERVICE_FILE_SYSTEMD_USER"
|
RemoveFile "$SERVICE_DIR_SYSTEMD_USER/$SERVICE_FILE_SYSTEMD_USER"
|
||||||
RemoveFile "$SERVICE_DIR_INIT/$SERVICE_FILE_INIT"
|
RemoveFile "$SERVICE_DIR_INIT/$SERVICE_FILE_INIT"
|
||||||
|
|
||||||
Logger "Skipping configuration files in [$CONF_DIR]. You may remove this directory manually." "SIMPLE"
|
Logger "Skipping configuration files in [$CONF_DIR]. You may remove this directory manually." "NOTICE"
|
||||||
}
|
}
|
||||||
|
|
||||||
function Usage {
|
function Usage {
|
||||||
@ -962,7 +952,7 @@ STATS_LINK="http://instcount.netpower.fr?program=$PROGRAM&version=$PROGRAM_VERSI
|
|||||||
|
|
||||||
if [ "$ACTION" == "uninstall" ]; then
|
if [ "$ACTION" == "uninstall" ]; then
|
||||||
RemoveAll
|
RemoveAll
|
||||||
Logger "$PROGRAM uninstalled." "SIMPLE"
|
Logger "$PROGRAM uninstalled." "NOTICE"
|
||||||
else
|
else
|
||||||
CreateDir "$CONF_DIR"
|
CreateDir "$CONF_DIR"
|
||||||
CreateDir "$BIN_DIR"
|
CreateDir "$BIN_DIR"
|
||||||
@ -971,10 +961,10 @@ else
|
|||||||
if [ "$PROGRAM" == "osync" ] || [ "$PROGRAM" == "pmocr" ]; then
|
if [ "$PROGRAM" == "osync" ] || [ "$PROGRAM" == "pmocr" ]; then
|
||||||
CopyServiceFiles
|
CopyServiceFiles
|
||||||
fi
|
fi
|
||||||
Logger "$PROGRAM installed. Use with $BIN_DIR/$PROGRAM_BINARY" "SIMPLE"
|
Logger "$PROGRAM installed. Use with $BIN_DIR/$PROGRAM_BINARY" "NOTICE"
|
||||||
if [ "$PROGRAM" == "osync" ] || [ "$PROGRAM" == "obackup" ]; then
|
if [ "$PROGRAM" == "osync" ] || [ "$PROGRAM" == "obackup" ]; then
|
||||||
echo ""
|
echo ""
|
||||||
Logger "If connecting remotely, consider setup ssh filter to enhance security." "SIMPLE"
|
Logger "If connecting remotely, consider setup ssh filter to enhance security." "NOTICE"
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -983,7 +973,7 @@ if [ $_STATS -eq 1 ]; then
|
|||||||
if [ $_LOGGER_SILENT == true ]; then
|
if [ $_LOGGER_SILENT == true ]; then
|
||||||
Statistics
|
Statistics
|
||||||
else
|
else
|
||||||
Logger "In order to make usage statistics, the script would like to connect to $STATS_LINK" "SIMPLE"
|
Logger "In order to make usage statistics, the script would like to connect to $STATS_LINK" "NOTICE"
|
||||||
read -r -p "No data except those in the url will be send. Allow [Y/n] " response
|
read -r -p "No data except those in the url will be send. Allow [Y/n] " response
|
||||||
case $response in
|
case $response in
|
||||||
[nN])
|
[nN])
|
||||||
|
@ -91,19 +91,19 @@ function RemoteLogger {
|
|||||||
|
|
||||||
if [ "$level" == "CRITICAL" ]; then
|
if [ "$level" == "CRITICAL" ]; then
|
||||||
_Logger "" "$prefix\e[1;33;41m$value\e[0m" true
|
_Logger "" "$prefix\e[1;33;41m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
elif [ "$level" == "ERROR" ]; then
|
elif [ "$level" == "ERROR" ]; then
|
||||||
_Logger "" "$prefix\e[31m$value\e[0m" true
|
_Logger "" "$prefix\e[31m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
elif [ "$level" == "WARN" ]; then
|
elif [ "$level" == "WARN" ]; then
|
||||||
_Logger "" "$prefix\e[33m$value\e[0m" true
|
_Logger "" "$prefix\e[33m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
@ -121,7 +121,7 @@ function RemoteLogger {
|
|||||||
_Logger "" "$prefix$value"
|
_Logger "" "$prefix$value"
|
||||||
return
|
return
|
||||||
elif [ "$level" == "DEBUG" ]; then
|
elif [ "$level" == "DEBUG" ]; then
|
||||||
if [ "$_DEBUG" == "yes" ]; then
|
if [ "$_DEBUG" == true ]; then
|
||||||
_Logger "" "$prefix$value"
|
_Logger "" "$prefix$value"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -146,8 +146,7 @@ function RemoteLogger {
|
|||||||
# NOTICE sent to stdout
|
# NOTICE sent to stdout
|
||||||
# VERBOSE sent to stdout if _LOGGER_VERBOSE=true
|
# VERBOSE sent to stdout if _LOGGER_VERBOSE=true
|
||||||
# ALWAYS is sent to stdout unless _LOGGER_SILENT=true
|
# ALWAYS is sent to stdout unless _LOGGER_SILENT=true
|
||||||
# DEBUG & PARANOIA_DEBUG are only sent to stdout if _DEBUG=yes
|
# DEBUG & PARANOIA_DEBUG are only sent to stdout if _DEBUG=true
|
||||||
# SIMPLE is a wrapper for QuickLogger that does not use advanced functionality
|
|
||||||
function Logger {
|
function Logger {
|
||||||
local value="${1}" # Sentence to log (in double quotes)
|
local value="${1}" # Sentence to log (in double quotes)
|
||||||
local level="${2}" # Log level
|
local level="${2}" # Log level
|
||||||
@ -197,17 +196,10 @@ function Logger {
|
|||||||
_Logger "$prefix$value" "$prefix$value"
|
_Logger "$prefix$value" "$prefix$value"
|
||||||
return
|
return
|
||||||
elif [ "$level" == "DEBUG" ]; then
|
elif [ "$level" == "DEBUG" ]; then
|
||||||
if [ "$_DEBUG" == "yes" ]; then
|
if [ "$_DEBUG" == true ]; then
|
||||||
_Logger "$prefix$value" "$prefix$value"
|
_Logger "$prefix$value" "$prefix$value"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
elif [ "$level" == "SIMPLE" ]; then
|
|
||||||
if [ "$_LOGGER_SILENT" == true ]; then
|
|
||||||
_Logger "$preix$value"
|
|
||||||
else
|
|
||||||
_Logger "$preix$value" "$prefix$value"
|
|
||||||
fi
|
|
||||||
return
|
|
||||||
else
|
else
|
||||||
_Logger "\e[41mLogger function called without proper loglevel [$level].\e[0m" "\e[41mLogger function called without proper loglevel [$level].\e[0m" true
|
_Logger "\e[41mLogger function called without proper loglevel [$level].\e[0m" "\e[41mLogger function called without proper loglevel [$level].\e[0m" true
|
||||||
_Logger "Value was: $prefix$value" "Value was: $prefix$value" true
|
_Logger "Value was: $prefix$value" "Value was: $prefix$value" true
|
||||||
|
310
obackup.sh
310
obackup.sh
@ -8,11 +8,11 @@ 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-RC1
|
PROGRAM_VERSION=2.1-RC1
|
||||||
PROGRAM_BUILD=2018110602
|
PROGRAM_BUILD=2018110602
|
||||||
IS_STABLE=yes
|
IS_STABLE=true
|
||||||
|
|
||||||
|
|
||||||
_OFUNCTIONS_VERSION=2.3.0-RC2
|
_OFUNCTIONS_VERSION=2.3.0-RC2
|
||||||
_OFUNCTIONS_BUILD=2018122103
|
_OFUNCTIONS_BUILD=2019012801
|
||||||
_OFUNCTIONS_BOOTSTRAP=true
|
_OFUNCTIONS_BOOTSTRAP=true
|
||||||
|
|
||||||
if ! type "$BASH" > /dev/null; then
|
if ! type "$BASH" > /dev/null; then
|
||||||
@ -44,9 +44,9 @@ ERROR_ALERT=false
|
|||||||
WARN_ALERT=false
|
WARN_ALERT=false
|
||||||
|
|
||||||
|
|
||||||
## allow debugging from command line with _DEBUG=yes
|
## allow debugging from command line with _DEBUG=true
|
||||||
if [ ! "$_DEBUG" == "yes" ]; then
|
if [ ! "$_DEBUG" == true ]; then
|
||||||
_DEBUG=no
|
_DEBUG=false
|
||||||
_LOGGER_VERBOSE=false
|
_LOGGER_VERBOSE=false
|
||||||
else
|
else
|
||||||
trap 'TrapError ${LINENO} $?' ERR
|
trap 'TrapError ${LINENO} $?' ERR
|
||||||
@ -77,7 +77,6 @@ else
|
|||||||
LOG_FILE="/tmp/$PROGRAM.log"
|
LOG_FILE="/tmp/$PROGRAM.log"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#### RUN_DIR SUBSET ####
|
|
||||||
## Default directory where to store temporary run files
|
## Default directory where to store temporary run files
|
||||||
|
|
||||||
if [ -w /tmp ]; then
|
if [ -w /tmp ]; then
|
||||||
@ -93,7 +92,6 @@ if [ "$_REMOTE_EXECUTION" == true ]; then
|
|||||||
mkdir -p "$RUN_DIR/$PROGRAM.remote"
|
mkdir -p "$RUN_DIR/$PROGRAM.remote"
|
||||||
RUN_DIR="$RUN_DIR/$PROGRAM.remote"
|
RUN_DIR="$RUN_DIR/$PROGRAM.remote"
|
||||||
fi
|
fi
|
||||||
#### RUN_DIR SUBSET END ####
|
|
||||||
|
|
||||||
# Get a random number on Windows BusyBox alike, also works on most Unixes that have dd, if dd is not found, then return $RANDOM
|
# Get a random number on Windows BusyBox alike, also works on most Unixes that have dd, if dd is not found, then return $RANDOM
|
||||||
function PoorMansRandomGenerator {
|
function PoorMansRandomGenerator {
|
||||||
@ -195,19 +193,19 @@ function RemoteLogger {
|
|||||||
|
|
||||||
if [ "$level" == "CRITICAL" ]; then
|
if [ "$level" == "CRITICAL" ]; then
|
||||||
_Logger "" "$prefix\e[1;33;41m$value\e[0m" true
|
_Logger "" "$prefix\e[1;33;41m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
elif [ "$level" == "ERROR" ]; then
|
elif [ "$level" == "ERROR" ]; then
|
||||||
_Logger "" "$prefix\e[31m$value\e[0m" true
|
_Logger "" "$prefix\e[31m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
elif [ "$level" == "WARN" ]; then
|
elif [ "$level" == "WARN" ]; then
|
||||||
_Logger "" "$prefix\e[33m$value\e[0m" true
|
_Logger "" "$prefix\e[33m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
@ -225,7 +223,7 @@ function RemoteLogger {
|
|||||||
_Logger "" "$prefix$value"
|
_Logger "" "$prefix$value"
|
||||||
return
|
return
|
||||||
elif [ "$level" == "DEBUG" ]; then
|
elif [ "$level" == "DEBUG" ]; then
|
||||||
if [ "$_DEBUG" == "yes" ]; then
|
if [ "$_DEBUG" == true ]; then
|
||||||
_Logger "" "$prefix$value"
|
_Logger "" "$prefix$value"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -249,8 +247,7 @@ function RemoteLogger {
|
|||||||
# NOTICE sent to stdout
|
# NOTICE sent to stdout
|
||||||
# VERBOSE sent to stdout if _LOGGER_VERBOSE=true
|
# VERBOSE sent to stdout if _LOGGER_VERBOSE=true
|
||||||
# ALWAYS is sent to stdout unless _LOGGER_SILENT=true
|
# ALWAYS is sent to stdout unless _LOGGER_SILENT=true
|
||||||
# DEBUG & PARANOIA_DEBUG are only sent to stdout if _DEBUG=yes
|
# DEBUG & PARANOIA_DEBUG are only sent to stdout if _DEBUG=true
|
||||||
# SIMPLE is a wrapper for QuickLogger that does not use advanced functionality
|
|
||||||
function Logger {
|
function Logger {
|
||||||
local value="${1}" # Sentence to log (in double quotes)
|
local value="${1}" # Sentence to log (in double quotes)
|
||||||
local level="${2}" # Log level
|
local level="${2}" # Log level
|
||||||
@ -300,17 +297,10 @@ function Logger {
|
|||||||
_Logger "$prefix$value" "$prefix$value"
|
_Logger "$prefix$value" "$prefix$value"
|
||||||
return
|
return
|
||||||
elif [ "$level" == "DEBUG" ]; then
|
elif [ "$level" == "DEBUG" ]; then
|
||||||
if [ "$_DEBUG" == "yes" ]; then
|
if [ "$_DEBUG" == true ]; then
|
||||||
_Logger "$prefix$value" "$prefix$value"
|
_Logger "$prefix$value" "$prefix$value"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
elif [ "$level" == "SIMPLE" ]; then
|
|
||||||
if [ "$_LOGGER_SILENT" == true ]; then
|
|
||||||
_Logger "$preix$value"
|
|
||||||
else
|
|
||||||
_Logger "$preix$value" "$prefix$value"
|
|
||||||
fi
|
|
||||||
return
|
|
||||||
else
|
else
|
||||||
_Logger "\e[41mLogger function called without proper loglevel [$level].\e[0m" "\e[41mLogger function called without proper loglevel [$level].\e[0m" true
|
_Logger "\e[41mLogger function called without proper loglevel [$level].\e[0m" "\e[41mLogger function called without proper loglevel [$level].\e[0m" true
|
||||||
_Logger "Value was: $prefix$value" "Value was: $prefix$value" true
|
_Logger "Value was: $prefix$value" "Value was: $prefix$value" true
|
||||||
@ -403,7 +393,7 @@ function KillAllChilds {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function CleanUp {
|
function CleanUp {
|
||||||
if [ "$_DEBUG" != "yes" ]; then
|
if [ "$_DEBUG" != true ]; then
|
||||||
rm -f "$RUN_DIR/$PROGRAM."*".$SCRIPT_PID.$TSTAMP"
|
rm -f "$RUN_DIR/$PROGRAM."*".$SCRIPT_PID.$TSTAMP"
|
||||||
# Fix for sed -i requiring backup extension for BSD & Mac (see all sed -i statements)
|
# Fix for sed -i requiring backup extension for BSD & Mac (see all sed -i statements)
|
||||||
rm -f "$RUN_DIR/$PROGRAM."*".$SCRIPT_PID.$TSTAMP.tmp"
|
rm -f "$RUN_DIR/$PROGRAM."*".$SCRIPT_PID.$TSTAMP.tmp"
|
||||||
@ -443,7 +433,7 @@ function SendAlert {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$_DEBUG" == "yes" ]; then
|
if [ "$_DEBUG" == true ]; then
|
||||||
Logger "Debug mode, no warning mail will be sent." "NOTICE"
|
Logger "Debug mode, no warning mail will be sent." "NOTICE"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@ -521,8 +511,9 @@ function SendEmail {
|
|||||||
|
|
||||||
local i
|
local i
|
||||||
|
|
||||||
if [ "${destinationMails[@]}" != "" ]; then
|
if [ "${destinationMails}" != "" ]; then
|
||||||
for i in "${destinationMails[@]}"; do
|
# Not quoted since we split at space character, and emails cannot contain spaces
|
||||||
|
for i in ${destinationMails}; do
|
||||||
if [ $(CheckRFC822 "$i") -ne 1 ]; then
|
if [ $(CheckRFC822 "$i") -ne 1 ]; then
|
||||||
Logger "Given email [$i] does not seem to be valid." "WARN"
|
Logger "Given email [$i] does not seem to be valid." "WARN"
|
||||||
fi
|
fi
|
||||||
@ -701,7 +692,7 @@ function LoadConfigFile {
|
|||||||
else
|
else
|
||||||
revisionPresent=$(GetConfFileValue "$configFile" "CONFIG_FILE_REVISION" true)
|
revisionPresent=$(GetConfFileValue "$configFile" "CONFIG_FILE_REVISION" true)
|
||||||
if [ "$(IsNumeric $revisionPresent)" -eq 0 ]; then
|
if [ "$(IsNumeric $revisionPresent)" -eq 0 ]; then
|
||||||
revisionPresent=0
|
Logger "CONFIG_FILE_REVISION does not seem numeric [$revisionPresent]." "DEBUG"
|
||||||
fi
|
fi
|
||||||
if [ "$revisionRequired" != "" ]; then
|
if [ "$revisionRequired" != "" ]; then
|
||||||
if [ $(VerComp "$revisionPresent" "$revisionRequired") -eq 2 ]; then
|
if [ $(VerComp "$revisionPresent" "$revisionRequired") -eq 2 ]; then
|
||||||
@ -825,7 +816,7 @@ function ExecTasks {
|
|||||||
|
|
||||||
|
|
||||||
# Since ExecTasks takes up to 17 arguments, do a quick preflight check in DEBUG mode
|
# Since ExecTasks takes up to 17 arguments, do a quick preflight check in DEBUG mode
|
||||||
if [ "$_DEBUG" == "yes" ]; then
|
if [ "$_DEBUG" == true ]; then
|
||||||
declare -a booleans=(readFromFile counting spinner noTimeErrorLog noErrorLogsAtAll)
|
declare -a booleans=(readFromFile counting spinner noTimeErrorLog noErrorLogsAtAll)
|
||||||
for i in "${booleans[@]}"; do
|
for i in "${booleans[@]}"; do
|
||||||
test="if [ \$$i != false ] && [ \$$i != true ]; then Logger \"Bogus $i value [\$$i] given to ${FUNCNAME[0]}.\" \"CRITICAL\"; exit 1; fi"
|
test="if [ \$$i != false ] && [ \$$i != true ]; then Logger \"Bogus $i value [\$$i] given to ${FUNCNAME[0]}.\" \"CRITICAL\"; exit 1; fi"
|
||||||
@ -1420,7 +1411,7 @@ function GetLocalOS {
|
|||||||
LOCAL_OS="BusyBox"
|
LOCAL_OS="BusyBox"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if [ "$IGNORE_OS_TYPE" == "yes" ]; then
|
if [ "$IGNORE_OS_TYPE" == true ]; then
|
||||||
Logger "Running on unknown local OS [$localOsVar]." "WARN"
|
Logger "Running on unknown local OS [$localOsVar]." "WARN"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -1477,7 +1468,7 @@ function GetLocalOS {
|
|||||||
|
|
||||||
function GetRemoteOS {
|
function GetRemoteOS {
|
||||||
|
|
||||||
if [ "$REMOTE_OPERATION" != "yes" ]; then
|
if [ "$REMOTE_OPERATION" != true ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1594,7 +1585,7 @@ ENDSSH
|
|||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if [ "$IGNORE_OS_TYPE" == "yes" ]; then #DOC: Undocumented debug only setting
|
if [ "$IGNORE_OS_TYPE" == true ]; then #DOC: Undocumented debug only setting
|
||||||
Logger "Running on unknown remote OS [$remoteOsVar]." "WARN"
|
Logger "Running on unknown remote OS [$remoteOsVar]." "WARN"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -1633,7 +1624,7 @@ function RunLocalCommand {
|
|||||||
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "NOTICE"
|
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "NOTICE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$STOP_ON_CMD_ERROR" == "yes" ] && [ $retval -ne 0 ]; then
|
if [ "$STOP_ON_CMD_ERROR" == true ] && [ $retval -ne 0 ]; then
|
||||||
Logger "Stopping on command execution error." "CRITICAL"
|
Logger "Stopping on command execution error." "CRITICAL"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -1645,7 +1636,7 @@ function RunRemoteCommand {
|
|||||||
local hardMaxTime="${2}" # Max time to wait for command to compleet
|
local hardMaxTime="${2}" # Max time to wait for command to compleet
|
||||||
|
|
||||||
|
|
||||||
if [ "$REMOTE_OPERATION" != "yes" ]; then
|
if [ "$REMOTE_OPERATION" != true ]; then
|
||||||
Logger "Ignoring remote command [$command] because remote host is not configured." "WARN"
|
Logger "Ignoring remote command [$command] because remote host is not configured." "WARN"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@ -1675,7 +1666,7 @@ function RunRemoteCommand {
|
|||||||
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "NOTICE"
|
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "NOTICE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$STOP_ON_CMD_ERROR" == "yes" ] && [ $retval -ne 0 ]; then
|
if [ "$STOP_ON_CMD_ERROR" == true ] && [ $retval -ne 0 ]; then
|
||||||
Logger "Stopping on command execution error." "CRITICAL"
|
Logger "Stopping on command execution error." "CRITICAL"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -1724,7 +1715,7 @@ function CheckConnectivityRemoteHost {
|
|||||||
local retval
|
local retval
|
||||||
|
|
||||||
|
|
||||||
if [ "$REMOTE_HOST_PING" != "no" ] && [ "$REMOTE_OPERATION" != "no" ]; then
|
if [ "$REMOTE_HOST_PING" != false ] && [ "$REMOTE_OPERATION" != false ]; then
|
||||||
eval "$PING_CMD $REMOTE_HOST > /dev/null 2>&1" &
|
eval "$PING_CMD $REMOTE_HOST > /dev/null 2>&1" &
|
||||||
ExecTasks $! "${FUNCNAME[0]}" false 0 0 60 180 true $SLEEP_TIME $KEEP_LOGGING
|
ExecTasks $! "${FUNCNAME[0]}" false 0 0 60 180 true $SLEEP_TIME $KEEP_LOGGING
|
||||||
#ExecTasks "${FUNCNAME[0]}" 0 0 60 180 $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
|
#ExecTasks "${FUNCNAME[0]}" 0 0 60 180 $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
|
||||||
@ -1849,14 +1840,14 @@ function PreInit {
|
|||||||
local compressionString
|
local compressionString
|
||||||
|
|
||||||
## SSH compression
|
## SSH compression
|
||||||
if [ "$SSH_COMPRESSION" != "no" ]; then
|
if [ "$SSH_COMPRESSION" != false ]; then
|
||||||
SSH_COMP=-C
|
SSH_COMP=-C
|
||||||
else
|
else
|
||||||
SSH_COMP=
|
SSH_COMP=
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Ignore SSH known host verification
|
## Ignore SSH known host verification
|
||||||
if [ "$SSH_IGNORE_KNOWN_HOSTS" == "yes" ]; then
|
if [ "$SSH_IGNORE_KNOWN_HOSTS" == true ]; then
|
||||||
SSH_OPTS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
|
SSH_OPTS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1866,7 +1857,7 @@ function PreInit {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
## Sudo execution option
|
## Sudo execution option
|
||||||
if [ "$SUDO_EXEC" == "yes" ]; then
|
if [ "$SUDO_EXEC" == true ]; then
|
||||||
if [ "$RSYNC_REMOTE_PATH" != "" ]; then
|
if [ "$RSYNC_REMOTE_PATH" != "" ]; then
|
||||||
RSYNC_PATH="sudo $RSYNC_REMOTE_PATH/$RSYNC_EXECUTABLE"
|
RSYNC_PATH="sudo $RSYNC_REMOTE_PATH/$RSYNC_EXECUTABLE"
|
||||||
else
|
else
|
||||||
@ -2027,19 +2018,19 @@ function InitRemoteOSDependingSettings {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
RSYNC_ATTR_ARGS=""
|
RSYNC_ATTR_ARGS=""
|
||||||
if [ "$PRESERVE_PERMISSIONS" != "no" ]; then
|
if [ "$PRESERVE_PERMISSIONS" != false ]; then
|
||||||
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -p"
|
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -p"
|
||||||
fi
|
fi
|
||||||
if [ "$PRESERVE_OWNER" != "no" ]; then
|
if [ "$PRESERVE_OWNER" != false ]; then
|
||||||
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -o"
|
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -o"
|
||||||
fi
|
fi
|
||||||
if [ "$PRESERVE_GROUP" != "no" ]; then
|
if [ "$PRESERVE_GROUP" != false ]; then
|
||||||
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -g"
|
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -g"
|
||||||
fi
|
fi
|
||||||
if [ "$PRESERVE_EXECUTABILITY" != "no" ]; then
|
if [ "$PRESERVE_EXECUTABILITY" != false ]; then
|
||||||
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" --executability"
|
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" --executability"
|
||||||
fi
|
fi
|
||||||
if [ "$PRESERVE_ACL" == "yes" ]; then
|
if [ "$PRESERVE_ACL" == true ]; then
|
||||||
if [ "$LOCAL_OS" != "MacOSX" ] && [ "$REMOTE_OS" != "MacOSX" ] && [ "$LOCAL_OS" != "msys" ] && [ "$REMOTE_OS" != "msys" ] && [ "$LOCAL_OS" != "Cygwin" ] && [ "$REMOTE_OS" != "Cygwin" ] && [ "$LOCAL_OS" != "BusyBox" ] && [ "$REMOTE_OS" != "BusyBox" ] && [ "$LOCAL_OS" != "Android" ] && [ "$REMOTE_OS" != "Android" ]; then
|
if [ "$LOCAL_OS" != "MacOSX" ] && [ "$REMOTE_OS" != "MacOSX" ] && [ "$LOCAL_OS" != "msys" ] && [ "$REMOTE_OS" != "msys" ] && [ "$LOCAL_OS" != "Cygwin" ] && [ "$REMOTE_OS" != "Cygwin" ] && [ "$LOCAL_OS" != "BusyBox" ] && [ "$REMOTE_OS" != "BusyBox" ] && [ "$LOCAL_OS" != "Android" ] && [ "$REMOTE_OS" != "Android" ]; then
|
||||||
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -A"
|
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -A"
|
||||||
else
|
else
|
||||||
@ -2047,45 +2038,45 @@ function InitRemoteOSDependingSettings {
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "$PRESERVE_XATTR" == "yes" ]; then
|
if [ "$PRESERVE_XATTR" == true ]; then
|
||||||
if [ "$LOCAL_OS" != "MacOSX" ] && [ "$REMOTE_OS" != "MacOSX" ] && [ "$LOCAL_OS" != "msys" ] && [ "$REMOTE_OS" != "msys" ] && [ "$LOCAL_OS" != "Cygwin" ] && [ "$REMOTE_OS" != "Cygwin" ] && [ "$LOCAL_OS" != "BusyBox" ] && [ "$REMOTE_OS" != "BusyBox" ]; then
|
if [ "$LOCAL_OS" != "MacOSX" ] && [ "$REMOTE_OS" != "MacOSX" ] && [ "$LOCAL_OS" != "msys" ] && [ "$REMOTE_OS" != "msys" ] && [ "$LOCAL_OS" != "Cygwin" ] && [ "$REMOTE_OS" != "Cygwin" ] && [ "$LOCAL_OS" != "BusyBox" ] && [ "$REMOTE_OS" != "BusyBox" ]; then
|
||||||
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -X"
|
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -X"
|
||||||
else
|
else
|
||||||
Logger "Disabling extended attributes synchronization on [$LOCAL_OS] due to lack of support." "NOTICE"
|
Logger "Disabling extended attributes synchronization on [$LOCAL_OS] due to lack of support." "NOTICE"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "$RSYNC_COMPRESS" == "yes" ]; then
|
if [ "$RSYNC_COMPRESS" == true ]; then
|
||||||
if [ "$LOCAL_OS" != "MacOSX" ] && [ "$REMOTE_OS" != "MacOSX" ]; then
|
if [ "$LOCAL_OS" != "MacOSX" ] && [ "$REMOTE_OS" != "MacOSX" ]; then
|
||||||
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" -zz --skip-compress=gz/xz/lz/lzma/lzo/rz/jpg/mp3/mp4/7z/bz2/rar/zip/sfark/s7z/ace/apk/arc/cab/dmg/jar/kgb/lzh/lha/lzx/pak/sfx"
|
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" -zz --skip-compress=gz/xz/lz/lzma/lzo/rz/jpg/mp3/mp4/7z/bz2/rar/zip/sfark/s7z/ace/apk/arc/cab/dmg/jar/kgb/lzh/lha/lzx/pak/sfx"
|
||||||
else
|
else
|
||||||
Logger "Disabling compression skips on synchronization on [$LOCAL_OS] due to lack of support." "NOTICE"
|
Logger "Disabling compression skips on synchronization on [$LOCAL_OS] due to lack of support." "NOTICE"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "$COPY_SYMLINKS" == "yes" ]; then
|
if [ "$COPY_SYMLINKS" == true ]; then
|
||||||
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" -L"
|
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" -L"
|
||||||
fi
|
fi
|
||||||
if [ "$KEEP_DIRLINKS" == "yes" ]; then
|
if [ "$KEEP_DIRLINKS" == true ]; then
|
||||||
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" -K"
|
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" -K"
|
||||||
fi
|
fi
|
||||||
if [ "$RSYNC_OPTIONAL_ARGS" != "" ]; then
|
if [ "$RSYNC_OPTIONAL_ARGS" != "" ]; then
|
||||||
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" "$RSYNC_OPTIONAL_ARGS
|
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" "$RSYNC_OPTIONAL_ARGS
|
||||||
fi
|
fi
|
||||||
if [ "$PRESERVE_HARDLINKS" == "yes" ]; then
|
if [ "$PRESERVE_HARDLINKS" == true ]; then
|
||||||
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" -H"
|
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" -H"
|
||||||
fi
|
fi
|
||||||
if [ "$CHECKSUM" == "yes" ]; then
|
if [ "$CHECKSUM" == true ]; then
|
||||||
RSYNC_TYPE_ARGS=$RSYNC_TYPE_ARGS" --checksum"
|
RSYNC_TYPE_ARGS=$RSYNC_TYPE_ARGS" --checksum"
|
||||||
fi
|
fi
|
||||||
if [ "$BANDWIDTH" != "" ] && [ "$BANDWIDTH" != "0" ]; then
|
if [ "$BANDWIDTH" != "" ] && [ "$BANDWIDTH" != "0" ]; then
|
||||||
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" --bwlimit=$BANDWIDTH"
|
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" --bwlimit=$BANDWIDTH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$PARTIAL" == "yes" ]; then
|
if [ "$PARTIAL" == true ]; then
|
||||||
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" --partial --partial-dir=\"$PARTIAL_DIR\""
|
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" --partial --partial-dir=\"$PARTIAL_DIR\""
|
||||||
RSYNC_PARTIAL_EXCLUDE="--exclude=\"$PARTIAL_DIR\""
|
RSYNC_PARTIAL_EXCLUDE="--exclude=\"$PARTIAL_DIR\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$DELTA_COPIES" != "no" ]; then
|
if [ "$DELTA_COPIES" != false ]; then
|
||||||
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" --no-whole-file"
|
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" --no-whole-file"
|
||||||
else
|
else
|
||||||
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" --whole-file"
|
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" --whole-file"
|
||||||
@ -2278,14 +2269,14 @@ function TrapQuit {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $ERROR_ALERT == true ]; then
|
if [ $ERROR_ALERT == true ]; then
|
||||||
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
|
if [ "$RUN_AFTER_CMD_ON_ERROR" == true ]; then
|
||||||
RunAfterHook
|
RunAfterHook
|
||||||
fi
|
fi
|
||||||
Logger "$PROGRAM finished with errors." "ERROR"
|
Logger "$PROGRAM finished with errors." "ERROR"
|
||||||
SendAlert
|
SendAlert
|
||||||
exitcode=1
|
exitcode=1
|
||||||
elif [ $WARN_ALERT == true ]; then
|
elif [ $WARN_ALERT == true ]; then
|
||||||
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
|
if [ "$RUN_AFTER_CMD_ON_ERROR" == true ]; then
|
||||||
RunAfterHook
|
RunAfterHook
|
||||||
fi
|
fi
|
||||||
Logger "$PROGRAM finished with warnings." "WARN"
|
Logger "$PROGRAM finished with warnings." "WARN"
|
||||||
@ -2308,7 +2299,7 @@ function TrapQuit {
|
|||||||
|
|
||||||
function CheckEnvironment {
|
function CheckEnvironment {
|
||||||
|
|
||||||
if [ "$REMOTE_OPERATION" == "yes" ]; then
|
if [ "$REMOTE_OPERATION" == true ]; then
|
||||||
if ! type ssh > /dev/null 2>&1 ; then
|
if ! type ssh > /dev/null 2>&1 ; then
|
||||||
Logger "ssh not present. Cannot start backup." "CRITICAL"
|
Logger "ssh not present. Cannot start backup." "CRITICAL"
|
||||||
exit 1
|
exit 1
|
||||||
@ -2319,7 +2310,7 @@ function CheckEnvironment {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ "$SQL_BACKUP" != "no" ]; then
|
if [ "$SQL_BACKUP" != false ]; then
|
||||||
if ! type mysqldump > /dev/null 2>&1 ; then
|
if ! type mysqldump > /dev/null 2>&1 ; then
|
||||||
Logger "mysqldump not present. Cannot backup SQL." "CRITICAL"
|
Logger "mysqldump not present. Cannot backup SQL." "CRITICAL"
|
||||||
CAN_BACKUP_SQL=false
|
CAN_BACKUP_SQL=false
|
||||||
@ -2331,14 +2322,14 @@ function CheckEnvironment {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$FILE_BACKUP" != "no" ]; then
|
if [ "$FILE_BACKUP" != false ]; then
|
||||||
if ! type rsync > /dev/null 2>&1 ; then
|
if ! type rsync > /dev/null 2>&1 ; then
|
||||||
Logger "rsync not present. Cannot backup files." "CRITICAL"
|
Logger "rsync not present. Cannot backup files." "CRITICAL"
|
||||||
CAN_BACKUP_FILES=false
|
CAN_BACKUP_FILES=false
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$ENCRYPTION" == "yes" ]; then
|
if [ "$ENCRYPTION" == true ]; then
|
||||||
CheckCryptEnvironnment
|
CheckCryptEnvironnment
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -2364,15 +2355,20 @@ function CheckCryptEnvironnment {
|
|||||||
|
|
||||||
function CheckCurrentConfig {
|
function CheckCurrentConfig {
|
||||||
|
|
||||||
|
local test
|
||||||
|
local booleans
|
||||||
|
local num_vars
|
||||||
|
|
||||||
if [ "$INSTANCE_ID" == "" ]; then
|
if [ "$INSTANCE_ID" == "" ]; then
|
||||||
Logger "No INSTANCE_ID defined in config file." "CRITICAL"
|
Logger "No INSTANCE_ID defined in config file." "CRITICAL"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check all variables that should contain "yes" or "no"
|
# v2 config will use true / false instead of yes / no
|
||||||
declare -a yes_no_vars=(SQL_BACKUP FILE_BACKUP ENCRYPTION CREATE_DIRS KEEP_ABSOLUTE_PATHS GET_BACKUP_SIZE SSH_COMPRESSION SSH_IGNORE_KNOWN_HOSTS REMOTE_HOST_PING SUDO_EXEC DATABASES_ALL PRESERVE_PERMISSIONS PRESERVE_OWNER PRESERVE_GROUP PRESERVE_EXECUTABILITY PRESERVE_ACL PRESERVE_XATTR COPY_SYMLINKS KEEP_DIRLINKS PRESERVE_HARDLINKS RSYNC_COMPRESS PARTIAL DELETE_VANISHED_FILES DELTA_COPIES ROTATE_SQL_BACKUPS ROTATE_FILE_BACKUPS STOP_ON_CMD_ERROR RUN_AFTER_CMD_ON_ERROR)
|
# Check all variables that should contain "yes" or "no", true or false
|
||||||
for i in "${yes_no_vars[@]}"; do
|
declare -a booleans=(SQL_BACKUP FILE_BACKUP ENCRYPTION CREATE_DIRS KEEP_ABSOLUTE_PATHS GET_BACKUP_SIZE SSH_COMPRESSION SSH_IGNORE_KNOWN_HOSTS REMOTE_HOST_PING SUDO_EXEC DATABASES_ALL PRESERVE_PERMISSIONS PRESERVE_OWNER PRESERVE_GROUP PRESERVE_EXECUTABILITY PRESERVE_ACL PRESERVE_XATTR COPY_SYMLINKS KEEP_DIRLINKS PRESERVE_HARDLINKS RSYNC_COMPRESS PARTIAL DELETE_VANISHED_FILES DELTA_COPIES ROTATE_SQL_BACKUPS ROTATE_FILE_BACKUPS STOP_ON_CMD_ERROR RUN_AFTER_CMD_ON_ERROR)
|
||||||
test="if [ \"\$$i\" != \"yes\" ] && [ \"\$$i\" != \"no\" ]; then Logger \"Bogus $i value [\$$i] defined in config file. Correct your config file or update it with the update script if using and old version.\" \"CRITICAL\"; exit 1; fi"
|
for i in "${booleans[@]}"; do
|
||||||
|
test="if [ \"\$$i\" != \"yes\" ] && [ \"\$$i\" != \"no\" ] && [ \"\$$i\" != true ] && [ \"\$$i\" != false ]; then Logger \"Bogus $i value [\$$i] defined in config file. Correct your config file or update it with the update script if using and old version.\" \"CRITICAL\"; exit 1; fi"
|
||||||
eval "$test"
|
eval "$test"
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -2388,14 +2384,14 @@ function CheckCurrentConfig {
|
|||||||
eval "$test"
|
eval "$test"
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$FILE_BACKUP" == "yes" ]; then
|
if [ "$FILE_BACKUP" == true ]; then
|
||||||
if [ "$DIRECTORY_LIST" == "" ] && [ "$RECURSIVE_DIRECTORY_LIST" == "" ]; then
|
if [ "$DIRECTORY_LIST" == "" ] && [ "$RECURSIVE_DIRECTORY_LIST" == "" ]; then
|
||||||
Logger "No directories specified in config file, no files to backup." "ERROR"
|
Logger "No directories specified in config file, no files to backup." "ERROR"
|
||||||
CAN_BACKUP_FILES=false
|
CAN_BACKUP_FILES=false
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$REMOTE_OPERATION" == "yes" ] && [ ! -f "$SSH_RSA_PRIVATE_KEY" ]; then
|
if [ "$REMOTE_OPERATION" == true ] && [ ! -f "$SSH_RSA_PRIVATE_KEY" ]; then
|
||||||
Logger "Cannot find rsa private key [$SSH_RSA_PRIVATE_KEY]. Cannot connect to remote system." "CRITICAL"
|
Logger "Cannot find rsa private key [$SSH_RSA_PRIVATE_KEY]. Cannot connect to remote system." "CRITICAL"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -2406,17 +2402,17 @@ function CheckCurrentConfig {
|
|||||||
# exit 1
|
# exit 1
|
||||||
#fi
|
#fi
|
||||||
|
|
||||||
if [ "$SQL_BACKUP" == "yes" ] && [ "$SQL_STORAGE" == "" ]; then
|
if [ "$SQL_BACKUP" == true ] && [ "$SQL_STORAGE" == "" ]; then
|
||||||
Logger "SQL_STORAGE not defined." "CRITICAL"
|
Logger "SQL_STORAGE not defined." "CRITICAL"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$FILE_BACKUP" == "yes" ] && [ "$FILE_STORAGE" == "" ]; then
|
if [ "$FILE_BACKUP" == true ] && [ "$FILE_STORAGE" == "" ]; then
|
||||||
Logger "FILE_STORAGE not defined." "CRITICAL"
|
Logger "FILE_STORAGE not defined." "CRITICAL"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$ENCRYPTION" == "yes" ]; then
|
if [ "$ENCRYPTION" == true ]; then
|
||||||
if [ "$CRYPT_STORAGE" == "" ]; then
|
if [ "$CRYPT_STORAGE" == "" ]; then
|
||||||
Logger "CRYPT_STORAGE not defined." "CRITICAL"
|
Logger "CRYPT_STORAGE not defined." "CRITICAL"
|
||||||
exit 1
|
exit 1
|
||||||
@ -2427,12 +2423,25 @@ function CheckCurrentConfig {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$REMOTE_OPERATION" == "yes" ] && ([ ! -f "$SSH_RSA_PRIVATE_KEY" ] && [ ! -f "$SSH_PASSWORD_FILE" ]); then
|
if [ "$REMOTE_OPERATION" == true ] && ([ ! -f "$SSH_RSA_PRIVATE_KEY" ] && [ ! -f "$SSH_PASSWORD_FILE" ]); then
|
||||||
Logger "Cannot find rsa private key [$SSH_RSA_PRIVATE_KEY] nor password file [$SSH_PASSWORD_FILE]. No authentication method provided." "CRITICAL"
|
Logger "Cannot find rsa private key [$SSH_RSA_PRIVATE_KEY] nor password file [$SSH_PASSWORD_FILE]. No authentication method provided." "CRITICAL"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Change all booleans with "yes" or "no" to true / false for v2 config syntax compatibility
|
||||||
|
function UpdateBooleans {
|
||||||
|
local update
|
||||||
|
local booleans
|
||||||
|
|
||||||
|
declare -a booleans=(SQL_BACKUP FILE_BACKUP ENCRYPTION CREATE_DIRS KEEP_ABSOLUTE_PATHS GET_BACKUP_SIZE SSH_COMPRESSION SSH_IGNORE_KNOWN_HOSTS REMOTE_HOST_PING SUDO_EXEC DATABASES_ALL PRESERVE_PERMISSIONS PRESERVE_OWNER PRESERVE_GROUP PRESERVE_EXECUTABILITY PRESERVE_ACL PRESERVE_XATTR COPY_SYMLINKS KEEP_DIRLINKS PRESERVE_HARDLINKS RSYNC_COMPRESS PARTIAL DELETE_VANISHED_FILES DELTA_COPIES ROTATE_SQL_BACKUPS ROTATE_FILE_BACKUPS STOP_ON_CMD_ERROR RUN_AFTER_CMD_ON_ERROR)
|
||||||
|
|
||||||
|
for i in "${booleans[@]}"; do
|
||||||
|
update="if [ \"\$$i\" == \"yes\" ]; then $i=true; fi; if [ \"\$$i\" == \"no\" ]; then $i=false; fi"
|
||||||
|
eval "$update"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
function CheckRunningInstances {
|
function CheckRunningInstances {
|
||||||
|
|
||||||
if [ -f "$RUN_DIR/$PROGRAM.$INSTANCE_ID" ]; then
|
if [ -f "$RUN_DIR/$PROGRAM.$INSTANCE_ID" ]; then
|
||||||
@ -2530,7 +2539,7 @@ function ListDatabases {
|
|||||||
while read -r line; do
|
while read -r line; do
|
||||||
while read -r name size; do dbName=$name; dbSize=$size; done <<< "$line"
|
while read -r name size; do dbName=$name; dbSize=$size; done <<< "$line"
|
||||||
|
|
||||||
if [ "$DATABASES_ALL" == "yes" ]; then
|
if [ "$DATABASES_ALL" == true ]; then
|
||||||
dbBackup=true
|
dbBackup=true
|
||||||
IFS=$PATH_SEPARATOR_CHAR read -r -a dbArray <<< "$DATABASES_ALL_EXCLUDE_LIST"
|
IFS=$PATH_SEPARATOR_CHAR read -r -a dbArray <<< "$DATABASES_ALL_EXCLUDE_LIST"
|
||||||
for j in "${dbArray[@]}"; do
|
for j in "${dbArray[@]}"; do
|
||||||
@ -2632,9 +2641,9 @@ env _REMOTE_EXECUTION="true" env PROGRAM="'$PROGRAM'" env SCRIPT_PID="'$SCRIPT_P
|
|||||||
env RECURSIVE_DIRECTORY_LIST="'$RECURSIVE_DIRECTORY_LIST'" env PATH_SEPARATOR_CHAR="'$PATH_SEPARATOR_CHAR'" \
|
env RECURSIVE_DIRECTORY_LIST="'$RECURSIVE_DIRECTORY_LIST'" env PATH_SEPARATOR_CHAR="'$PATH_SEPARATOR_CHAR'" \
|
||||||
env REMOTE_FIND_CMD="'$REMOTE_FIND_CMD'" $COMMAND_SUDO' bash -s' << 'ENDSSH' > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" 2> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP"
|
env REMOTE_FIND_CMD="'$REMOTE_FIND_CMD'" $COMMAND_SUDO' bash -s' << 'ENDSSH' > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" 2> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP"
|
||||||
|
|
||||||
## allow debugging from command line with _DEBUG=yes
|
## allow debugging from command line with _DEBUG=true
|
||||||
if [ ! "$_DEBUG" == "yes" ]; then
|
if [ ! "$_DEBUG" == true ]; then
|
||||||
_DEBUG=no
|
_DEBUG=false
|
||||||
_LOGGER_VERBOSE=false
|
_LOGGER_VERBOSE=false
|
||||||
else
|
else
|
||||||
trap 'TrapError ${LINENO} $?' ERR
|
trap 'TrapError ${LINENO} $?' ERR
|
||||||
@ -2704,19 +2713,19 @@ function RemoteLogger {
|
|||||||
|
|
||||||
if [ "$level" == "CRITICAL" ]; then
|
if [ "$level" == "CRITICAL" ]; then
|
||||||
_Logger "" "$prefix\e[1;33;41m$value\e[0m" true
|
_Logger "" "$prefix\e[1;33;41m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
elif [ "$level" == "ERROR" ]; then
|
elif [ "$level" == "ERROR" ]; then
|
||||||
_Logger "" "$prefix\e[31m$value\e[0m" true
|
_Logger "" "$prefix\e[31m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
elif [ "$level" == "WARN" ]; then
|
elif [ "$level" == "WARN" ]; then
|
||||||
_Logger "" "$prefix\e[33m$value\e[0m" true
|
_Logger "" "$prefix\e[33m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
@ -2734,7 +2743,7 @@ function RemoteLogger {
|
|||||||
_Logger "" "$prefix$value"
|
_Logger "" "$prefix$value"
|
||||||
return
|
return
|
||||||
elif [ "$level" == "DEBUG" ]; then
|
elif [ "$level" == "DEBUG" ]; then
|
||||||
if [ "$_DEBUG" == "yes" ]; then
|
if [ "$_DEBUG" == true ]; then
|
||||||
_Logger "" "$prefix$value"
|
_Logger "" "$prefix$value"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -2915,9 +2924,9 @@ env _REMOTE_EXECUTION="true" env PROGRAM="'$PROGRAM'" env SCRIPT_PID="'$SCRIPT_P
|
|||||||
dirList="'$dirList'" \
|
dirList="'$dirList'" \
|
||||||
$COMMAND_SUDO' bash -s' << 'ENDSSH' > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" 2> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP" &
|
$COMMAND_SUDO' bash -s' << 'ENDSSH' > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" 2> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP" &
|
||||||
|
|
||||||
## allow debugging from command line with _DEBUG=yes
|
## allow debugging from command line with _DEBUG=true
|
||||||
if [ ! "$_DEBUG" == "yes" ]; then
|
if [ ! "$_DEBUG" == true ]; then
|
||||||
_DEBUG=no
|
_DEBUG=false
|
||||||
_LOGGER_VERBOSE=false
|
_LOGGER_VERBOSE=false
|
||||||
else
|
else
|
||||||
trap 'TrapError ${LINENO} $?' ERR
|
trap 'TrapError ${LINENO} $?' ERR
|
||||||
@ -2987,19 +2996,19 @@ function RemoteLogger {
|
|||||||
|
|
||||||
if [ "$level" == "CRITICAL" ]; then
|
if [ "$level" == "CRITICAL" ]; then
|
||||||
_Logger "" "$prefix\e[1;33;41m$value\e[0m" true
|
_Logger "" "$prefix\e[1;33;41m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
elif [ "$level" == "ERROR" ]; then
|
elif [ "$level" == "ERROR" ]; then
|
||||||
_Logger "" "$prefix\e[31m$value\e[0m" true
|
_Logger "" "$prefix\e[31m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
elif [ "$level" == "WARN" ]; then
|
elif [ "$level" == "WARN" ]; then
|
||||||
_Logger "" "$prefix\e[33m$value\e[0m" true
|
_Logger "" "$prefix\e[33m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
@ -3017,7 +3026,7 @@ function RemoteLogger {
|
|||||||
_Logger "" "$prefix$value"
|
_Logger "" "$prefix$value"
|
||||||
return
|
return
|
||||||
elif [ "$level" == "DEBUG" ]; then
|
elif [ "$level" == "DEBUG" ]; then
|
||||||
if [ "$_DEBUG" == "yes" ]; then
|
if [ "$_DEBUG" == true ]; then
|
||||||
_Logger "" "$prefix$value"
|
_Logger "" "$prefix$value"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -3064,11 +3073,11 @@ function GetDirectoriesSize {
|
|||||||
Logger "Getting files size" "NOTICE"
|
Logger "Getting files size" "NOTICE"
|
||||||
|
|
||||||
if [ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]; then
|
if [ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]; then
|
||||||
if [ "$FILE_BACKUP" != "no" ]; then
|
if [ "$FILE_BACKUP" != false ]; then
|
||||||
_GetDirectoriesSizeLocal "$FILE_SIZE_LIST"
|
_GetDirectoriesSizeLocal "$FILE_SIZE_LIST"
|
||||||
fi
|
fi
|
||||||
elif [ "$BACKUP_TYPE" == "pull" ]; then
|
elif [ "$BACKUP_TYPE" == "pull" ]; then
|
||||||
if [ "$FILE_BACKUP" != "no" ]; then
|
if [ "$FILE_BACKUP" != false ]; then
|
||||||
_GetDirectoriesSizeRemote "$FILE_SIZE_LIST"
|
_GetDirectoriesSizeRemote "$FILE_SIZE_LIST"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -3108,9 +3117,9 @@ env _DEBUG="'$_DEBUG'" env _PARANOIA_DEBUG="'$_PARANOIA_DEBUG'" env _LOGGER_SILE
|
|||||||
env _REMOTE_EXECUTION="true" env PROGRAM="'$PROGRAM'" env SCRIPT_PID="'$SCRIPT_PID'" env TSTAMP="'$TSTAMP'" \
|
env _REMOTE_EXECUTION="true" env PROGRAM="'$PROGRAM'" env SCRIPT_PID="'$SCRIPT_PID'" env TSTAMP="'$TSTAMP'" \
|
||||||
env dirToCreate="'$dirToCreate'" $COMMAND_SUDO' bash -s' << 'ENDSSH' > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" 2>&1 &
|
env dirToCreate="'$dirToCreate'" $COMMAND_SUDO' bash -s' << 'ENDSSH' > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" 2>&1 &
|
||||||
|
|
||||||
## allow debugging from command line with _DEBUG=yes
|
## allow debugging from command line with _DEBUG=true
|
||||||
if [ ! "$_DEBUG" == "yes" ]; then
|
if [ ! "$_DEBUG" == true ]; then
|
||||||
_DEBUG=no
|
_DEBUG=false
|
||||||
_LOGGER_VERBOSE=false
|
_LOGGER_VERBOSE=false
|
||||||
else
|
else
|
||||||
trap 'TrapError ${LINENO} $?' ERR
|
trap 'TrapError ${LINENO} $?' ERR
|
||||||
@ -3180,19 +3189,19 @@ function RemoteLogger {
|
|||||||
|
|
||||||
if [ "$level" == "CRITICAL" ]; then
|
if [ "$level" == "CRITICAL" ]; then
|
||||||
_Logger "" "$prefix\e[1;33;41m$value\e[0m" true
|
_Logger "" "$prefix\e[1;33;41m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
elif [ "$level" == "ERROR" ]; then
|
elif [ "$level" == "ERROR" ]; then
|
||||||
_Logger "" "$prefix\e[31m$value\e[0m" true
|
_Logger "" "$prefix\e[31m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
elif [ "$level" == "WARN" ]; then
|
elif [ "$level" == "WARN" ]; then
|
||||||
_Logger "" "$prefix\e[33m$value\e[0m" true
|
_Logger "" "$prefix\e[33m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
@ -3210,7 +3219,7 @@ function RemoteLogger {
|
|||||||
_Logger "" "$prefix$value"
|
_Logger "" "$prefix$value"
|
||||||
return
|
return
|
||||||
elif [ "$level" == "DEBUG" ]; then
|
elif [ "$level" == "DEBUG" ]; then
|
||||||
if [ "$_DEBUG" == "yes" ]; then
|
if [ "$_DEBUG" == true ]; then
|
||||||
_Logger "" "$prefix$value"
|
_Logger "" "$prefix$value"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -3242,38 +3251,38 @@ ENDSSH
|
|||||||
function CreateStorageDirectories {
|
function CreateStorageDirectories {
|
||||||
|
|
||||||
if [ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "pull" ]; then
|
if [ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "pull" ]; then
|
||||||
if [ "$SQL_BACKUP" != "no" ]; then
|
if [ "$SQL_BACKUP" != false ]; then
|
||||||
_CreateDirectoryLocal "$SQL_STORAGE"
|
_CreateDirectoryLocal "$SQL_STORAGE"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
CAN_BACKUP_SQL=false
|
CAN_BACKUP_SQL=false
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "$FILE_BACKUP" != "no" ]; then
|
if [ "$FILE_BACKUP" != false ]; then
|
||||||
_CreateDirectoryLocal "$FILE_STORAGE"
|
_CreateDirectoryLocal "$FILE_STORAGE"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
CAN_BACKUP_FILES=false
|
CAN_BACKUP_FILES=false
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "$ENCRYPTION" == "yes" ]; then
|
if [ "$ENCRYPTION" == true ]; then
|
||||||
_CreateDirectoryLocal "$CRYPT_STORAGE"
|
_CreateDirectoryLocal "$CRYPT_STORAGE"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
CAN_BACKUP_FILES=false
|
CAN_BACKUP_FILES=false
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
elif [ "$BACKUP_TYPE" == "push" ]; then
|
elif [ "$BACKUP_TYPE" == "push" ]; then
|
||||||
if [ "$SQL_BACKUP" != "no" ]; then
|
if [ "$SQL_BACKUP" != false ]; then
|
||||||
_CreateDirectoryRemote "$SQL_STORAGE"
|
_CreateDirectoryRemote "$SQL_STORAGE"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
CAN_BACKUP_SQL=false
|
CAN_BACKUP_SQL=false
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "$FILE_BACKUP" != "no" ]; then
|
if [ "$FILE_BACKUP" != false ]; then
|
||||||
_CreateDirectoryRemote "$FILE_STORAGE"
|
_CreateDirectoryRemote "$FILE_STORAGE"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
CAN_BACKUP_FILES=false
|
CAN_BACKUP_FILES=false
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "$ENCRYPTION" == "yes" ]; then
|
if [ "$ENCRYPTION" == true ]; then
|
||||||
_CreateDirectoryLocal "$CRYPT_STORAGE"
|
_CreateDirectoryLocal "$CRYPT_STORAGE"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
CAN_BACKUP_FILES=false
|
CAN_BACKUP_FILES=false
|
||||||
@ -3327,9 +3336,9 @@ env _REMOTE_EXECUTION="true" env PROGRAM="'$PROGRAM'" env SCRIPT_PID="'$SCRIPT_P
|
|||||||
env DF_CMD="'$DF_CMD'" \
|
env DF_CMD="'$DF_CMD'" \
|
||||||
env pathToCheck="'$pathToCheck'" $COMMAND_SUDO' bash -s' << 'ENDSSH' > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" 2> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP" &
|
env pathToCheck="'$pathToCheck'" $COMMAND_SUDO' bash -s' << 'ENDSSH' > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" 2> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP" &
|
||||||
|
|
||||||
## allow debugging from command line with _DEBUG=yes
|
## allow debugging from command line with _DEBUG=true
|
||||||
if [ ! "$_DEBUG" == "yes" ]; then
|
if [ ! "$_DEBUG" == true ]; then
|
||||||
_DEBUG=no
|
_DEBUG=false
|
||||||
_LOGGER_VERBOSE=false
|
_LOGGER_VERBOSE=false
|
||||||
else
|
else
|
||||||
trap 'TrapError ${LINENO} $?' ERR
|
trap 'TrapError ${LINENO} $?' ERR
|
||||||
@ -3399,19 +3408,19 @@ function RemoteLogger {
|
|||||||
|
|
||||||
if [ "$level" == "CRITICAL" ]; then
|
if [ "$level" == "CRITICAL" ]; then
|
||||||
_Logger "" "$prefix\e[1;33;41m$value\e[0m" true
|
_Logger "" "$prefix\e[1;33;41m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
elif [ "$level" == "ERROR" ]; then
|
elif [ "$level" == "ERROR" ]; then
|
||||||
_Logger "" "$prefix\e[31m$value\e[0m" true
|
_Logger "" "$prefix\e[31m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
elif [ "$level" == "WARN" ]; then
|
elif [ "$level" == "WARN" ]; then
|
||||||
_Logger "" "$prefix\e[33m$value\e[0m" true
|
_Logger "" "$prefix\e[33m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
@ -3429,7 +3438,7 @@ function RemoteLogger {
|
|||||||
_Logger "" "$prefix$value"
|
_Logger "" "$prefix$value"
|
||||||
return
|
return
|
||||||
elif [ "$level" == "DEBUG" ]; then
|
elif [ "$level" == "DEBUG" ]; then
|
||||||
if [ "$_DEBUG" == "yes" ]; then
|
if [ "$_DEBUG" == true ]; then
|
||||||
_Logger "" "$prefix$value"
|
_Logger "" "$prefix$value"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -3483,7 +3492,7 @@ function CheckDiskSpace {
|
|||||||
|
|
||||||
|
|
||||||
if [ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "pull" ]; then
|
if [ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "pull" ]; then
|
||||||
if [ "$SQL_BACKUP" != "no" ]; then
|
if [ "$SQL_BACKUP" != false ]; then
|
||||||
GetDiskSpaceLocal "$SQL_STORAGE"
|
GetDiskSpaceLocal "$SQL_STORAGE"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
SQL_DISK_SPACE=0
|
SQL_DISK_SPACE=0
|
||||||
@ -3493,7 +3502,7 @@ function CheckDiskSpace {
|
|||||||
SQL_DRIVE=$DRIVE
|
SQL_DRIVE=$DRIVE
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "$FILE_BACKUP" != "no" ]; then
|
if [ "$FILE_BACKUP" != false ]; then
|
||||||
GetDiskSpaceLocal "$FILE_STORAGE"
|
GetDiskSpaceLocal "$FILE_STORAGE"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
FILE_DISK_SPACE=0
|
FILE_DISK_SPACE=0
|
||||||
@ -3503,7 +3512,7 @@ function CheckDiskSpace {
|
|||||||
FILE_DRIVE=$DRIVE
|
FILE_DRIVE=$DRIVE
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "$ENCRYPTION" != "no" ]; then
|
if [ "$ENCRYPTION" != false ]; then
|
||||||
GetDiskSpaceLocal "$CRYPT_STORAGE"
|
GetDiskSpaceLocal "$CRYPT_STORAGE"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
CRYPT_DISK_SPACE=0
|
CRYPT_DISK_SPACE=0
|
||||||
@ -3515,7 +3524,7 @@ function CheckDiskSpace {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
elif [ "$BACKUP_TYPE" == "push" ]; then
|
elif [ "$BACKUP_TYPE" == "push" ]; then
|
||||||
if [ "$SQL_BACKUP" != "no" ]; then
|
if [ "$SQL_BACKUP" != false ]; then
|
||||||
GetDiskSpaceRemote "$SQL_STORAGE"
|
GetDiskSpaceRemote "$SQL_STORAGE"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
SQL_DISK_SPACE=0
|
SQL_DISK_SPACE=0
|
||||||
@ -3524,7 +3533,7 @@ function CheckDiskSpace {
|
|||||||
SQL_DRIVE=$DRIVE
|
SQL_DRIVE=$DRIVE
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "$FILE_BACKUP" != "no" ]; then
|
if [ "$FILE_BACKUP" != false ]; then
|
||||||
GetDiskSpaceRemote "$FILE_STORAGE"
|
GetDiskSpaceRemote "$FILE_STORAGE"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
FILE_DISK_SPACE=0
|
FILE_DISK_SPACE=0
|
||||||
@ -3533,7 +3542,7 @@ function CheckDiskSpace {
|
|||||||
FILE_DRIVE=$DRIVE
|
FILE_DRIVE=$DRIVE
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "$ENCRYPTION" != "no" ]; then
|
if [ "$ENCRYPTION" != false ]; then
|
||||||
GetDiskSpaceLocal "$CRYPT_STORAGE"
|
GetDiskSpaceLocal "$CRYPT_STORAGE"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
CRYPT_DISK_SPACE=0
|
CRYPT_DISK_SPACE=0
|
||||||
@ -3554,7 +3563,7 @@ function CheckDiskSpace {
|
|||||||
TOTAL_FILES_SIZE=-1
|
TOTAL_FILES_SIZE=-1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$SQL_BACKUP" != "no" ] && [ $CAN_BACKUP_SQL == true ]; then
|
if [ "$SQL_BACKUP" != false ] && [ $CAN_BACKUP_SQL == true ]; then
|
||||||
if [ $SQL_DISK_SPACE -eq 0 ]; then
|
if [ $SQL_DISK_SPACE -eq 0 ]; then
|
||||||
Logger "Storage space in [$SQL_STORAGE] reported to be 0Ko." "WARN"
|
Logger "Storage space in [$SQL_STORAGE] reported to be 0Ko." "WARN"
|
||||||
fi
|
fi
|
||||||
@ -3567,7 +3576,7 @@ function CheckDiskSpace {
|
|||||||
Logger "SQL storage Space: $SQL_DISK_SPACE Ko - Databases size: $TOTAL_DATABASES_SIZE Ko" "NOTICE"
|
Logger "SQL storage Space: $SQL_DISK_SPACE Ko - Databases size: $TOTAL_DATABASES_SIZE Ko" "NOTICE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$FILE_BACKUP" != "no" ] && [ $CAN_BACKUP_FILES == true ]; then
|
if [ "$FILE_BACKUP" != false ] && [ $CAN_BACKUP_FILES == true ]; then
|
||||||
if [ $FILE_DISK_SPACE -eq 0 ]; then
|
if [ $FILE_DISK_SPACE -eq 0 ]; then
|
||||||
Logger "Storage space in [$FILE_STORAGE] reported to be 0 Ko." "WARN"
|
Logger "Storage space in [$FILE_STORAGE] reported to be 0 Ko." "WARN"
|
||||||
fi
|
fi
|
||||||
@ -3580,8 +3589,8 @@ function CheckDiskSpace {
|
|||||||
Logger "File storage space: $FILE_DISK_SPACE Ko - Files size: $TOTAL_FILES_SIZE Ko" "NOTICE"
|
Logger "File storage space: $FILE_DISK_SPACE Ko - Files size: $TOTAL_FILES_SIZE Ko" "NOTICE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$ENCRYPTION" == "yes" ]; then
|
if [ "$ENCRYPTION" == true ]; then
|
||||||
if [ "$SQL_BACKUP" != "no" ]; then
|
if [ "$SQL_BACKUP" != false ]; then
|
||||||
if [ "$SQL_DRIVE" == "$CRYPT_DRIVE" ]; then
|
if [ "$SQL_DRIVE" == "$CRYPT_DRIVE" ]; then
|
||||||
if [ $((SQL_DISK_SPACE/2)) -lt $((TOTAL_DATABASES_SIZE)) ]; then
|
if [ $((SQL_DISK_SPACE/2)) -lt $((TOTAL_DATABASES_SIZE)) ]; then
|
||||||
Logger "Disk space in [$SQL_STORAGE] and [$CRYPT_STORAGE] may be insufficient to backup SQL ($SQL_DISK_SPACE Ko available in $SQL_DRIVE) (non compressed databases calculation + crypt storage space)." "WARN"
|
Logger "Disk space in [$SQL_STORAGE] and [$CRYPT_STORAGE] may be insufficient to backup SQL ($SQL_DISK_SPACE Ko available in $SQL_DRIVE) (non compressed databases calculation + crypt storage space)." "WARN"
|
||||||
@ -3593,7 +3602,7 @@ function CheckDiskSpace {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$FILE_BACKUP" != "no" ]; then
|
if [ "$FILE_BACKUP" != false ]; then
|
||||||
if [ "$FILE_DRIVE" == "$CRYPT_DRIVE" ]; then
|
if [ "$FILE_DRIVE" == "$CRYPT_DRIVE" ]; then
|
||||||
if [ $((FILE_DISK_SPACE/2)) -lt $((TOTAL_FILES_SIZE)) ]; then
|
if [ $((FILE_DISK_SPACE/2)) -lt $((TOTAL_FILES_SIZE)) ]; then
|
||||||
Logger "Disk space in [$FILE_STORAGE] and [$CRYPT_STORAGE] may be insufficient to encrypt Sfiles ($FILE_DISK_SPACE Ko available in $FILE_DRIVE)." "WARN"
|
Logger "Disk space in [$FILE_STORAGE] and [$CRYPT_STORAGE] may be insufficient to encrypt Sfiles ($FILE_DISK_SPACE Ko available in $FILE_DRIVE)." "WARN"
|
||||||
@ -3608,7 +3617,7 @@ function CheckDiskSpace {
|
|||||||
Logger "Crypt storage space: $CRYPT_DISK_SPACE Ko" "NOTICE"
|
Logger "Crypt storage space: $CRYPT_DISK_SPACE Ko" "NOTICE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $BACKUP_SIZE_MINIMUM -gt $((TOTAL_DATABASES_SIZE+TOTAL_FILES_SIZE)) ] && [ "$GET_BACKUP_SIZE" != "no" ]; then
|
if [ $BACKUP_SIZE_MINIMUM -gt $((TOTAL_DATABASES_SIZE+TOTAL_FILES_SIZE)) ] && [ "$GET_BACKUP_SIZE" != false ]; then
|
||||||
Logger "Backup size is smaller than expected." "WARN"
|
Logger "Backup size is smaller than expected." "WARN"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -3765,7 +3774,7 @@ function BackupDatabase {
|
|||||||
mysqlOptions="$MYSQLDUMP_OPTIONS"
|
mysqlOptions="$MYSQLDUMP_OPTIONS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$ENCRYPTION" == "yes" ]; then
|
if [ "$ENCRYPTION" == true ]; then
|
||||||
encrypt=true
|
encrypt=true
|
||||||
Logger "Backing up encrypted database [$database]." "NOTICE"
|
Logger "Backing up encrypted database [$database]." "NOTICE"
|
||||||
else
|
else
|
||||||
@ -4069,7 +4078,7 @@ function FilesBackup {
|
|||||||
for backupTask in "${backupTasks[@]}"; do
|
for backupTask in "${backupTasks[@]}"; do
|
||||||
# Backup directories from simple list
|
# Backup directories from simple list
|
||||||
|
|
||||||
if [ "$KEEP_ABSOLUTE_PATHS" != "no" ]; then
|
if [ "$KEEP_ABSOLUTE_PATHS" != false ]; then
|
||||||
# Fix for backup of '/'
|
# Fix for backup of '/'
|
||||||
if [ "${backupTask#/}/" == "/" ]; then
|
if [ "${backupTask#/}/" == "/" ]; then
|
||||||
destinationDir="$FILE_STORAGE/"
|
destinationDir="$FILE_STORAGE/"
|
||||||
@ -4083,14 +4092,14 @@ function FilesBackup {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
Logger "Beginning file backup of [$backupTask] to [$destinationDir] as $BACKUP_TYPE backup." "NOTICE"
|
Logger "Beginning file backup of [$backupTask] to [$destinationDir] as $BACKUP_TYPE backup." "NOTICE"
|
||||||
if [ "$ENCRYPTION" == "yes" ] && ([ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]); then
|
if [ "$ENCRYPTION" == true ] && ([ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]); then
|
||||||
EncryptFiles "$backupTask" "$CRYPT_STORAGE" "$GPG_RECIPIENT" true true
|
EncryptFiles "$backupTask" "$CRYPT_STORAGE" "$GPG_RECIPIENT" true true
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
Rsync "$CRYPT_STORAGE/$backupTask" "$destinationDir" true
|
Rsync "$CRYPT_STORAGE/$backupTask" "$destinationDir" true
|
||||||
else
|
else
|
||||||
Logger "backup failed." "ERROR"
|
Logger "backup failed." "ERROR"
|
||||||
fi
|
fi
|
||||||
elif [ "$ENCRYPTION" == "yes" ] && [ "$BACKUP_TYPE" == "pull" ]; then
|
elif [ "$ENCRYPTION" == true ] && [ "$BACKUP_TYPE" == "pull" ]; then
|
||||||
Rsync "$backupTask" "$destinationDir" true
|
Rsync "$backupTask" "$destinationDir" true
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
EncryptFiles "$encryptDir" "$CRYPT_STORAGE/$backupTask" "$GPG_RECIPIENT" true false
|
EncryptFiles "$encryptDir" "$CRYPT_STORAGE/$backupTask" "$GPG_RECIPIENT" true false
|
||||||
@ -4105,7 +4114,7 @@ function FilesBackup {
|
|||||||
for backupTask in "${backupTasks[@]}"; do
|
for backupTask in "${backupTasks[@]}"; do
|
||||||
# Backup recursive directories without recursion
|
# Backup recursive directories without recursion
|
||||||
|
|
||||||
if [ "$KEEP_ABSOLUTE_PATHS" != "no" ]; then
|
if [ "$KEEP_ABSOLUTE_PATHS" != false ]; then
|
||||||
# Fix for backup of '/'
|
# Fix for backup of '/'
|
||||||
if [ "${backupTask#/}/" == "/" ]; then
|
if [ "${backupTask#/}/" == "/" ]; then
|
||||||
destinationDir="$FILE_STORAGE/"
|
destinationDir="$FILE_STORAGE/"
|
||||||
@ -4119,14 +4128,14 @@ function FilesBackup {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
Logger "Beginning non recursive file backup of [$backupTask] to [$destinationDir] as $BACKUP_TYPE backup." "NOTICE"
|
Logger "Beginning non recursive file backup of [$backupTask] to [$destinationDir] as $BACKUP_TYPE backup." "NOTICE"
|
||||||
if [ "$ENCRYPTION" == "yes" ] && ([ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]); then
|
if [ "$ENCRYPTION" == true ] && ([ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]); then
|
||||||
EncryptFiles "$backupTask" "$CRYPT_STORAGE" "$GPG_RECIPIENT" false true
|
EncryptFiles "$backupTask" "$CRYPT_STORAGE" "$GPG_RECIPIENT" false true
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
Rsync "$CRYPT_STORAGE/$backupTask" "$destinationDir" false
|
Rsync "$CRYPT_STORAGE/$backupTask" "$destinationDir" false
|
||||||
else
|
else
|
||||||
Logger "backup failed." "ERROR"
|
Logger "backup failed." "ERROR"
|
||||||
fi
|
fi
|
||||||
elif [ "$ENCRYPTION" == "yes" ] && [ "$BACKUP_TYPE" == "pull" ]; then
|
elif [ "$ENCRYPTION" == true ] && [ "$BACKUP_TYPE" == "pull" ]; then
|
||||||
Rsync "$backupTask" "$destinationDir" false
|
Rsync "$backupTask" "$destinationDir" false
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
EncryptFiles "$encryptDir" "$CRYPT_STORAGE/$backupTask" "$GPG_RECIPIENT" false false
|
EncryptFiles "$encryptDir" "$CRYPT_STORAGE/$backupTask" "$GPG_RECIPIENT" false false
|
||||||
@ -4141,7 +4150,7 @@ function FilesBackup {
|
|||||||
for backupTask in "${backupTasks[@]}"; do
|
for backupTask in "${backupTasks[@]}"; do
|
||||||
# Backup sub directories of recursive directories
|
# Backup sub directories of recursive directories
|
||||||
|
|
||||||
if [ "$KEEP_ABSOLUTE_PATHS" != "no" ]; then
|
if [ "$KEEP_ABSOLUTE_PATHS" != false ]; then
|
||||||
# Fix for backup of '/'
|
# Fix for backup of '/'
|
||||||
if [ "${backupTask#/}/" == "/" ]; then
|
if [ "${backupTask#/}/" == "/" ]; then
|
||||||
destinationDir="$FILE_STORAGE/"
|
destinationDir="$FILE_STORAGE/"
|
||||||
@ -4155,14 +4164,14 @@ function FilesBackup {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
Logger "Beginning recursive child file backup of [$backupTask] to [$destinationDir] as $BACKUP_TYPE backup." "NOTICE"
|
Logger "Beginning recursive child file backup of [$backupTask] to [$destinationDir] as $BACKUP_TYPE backup." "NOTICE"
|
||||||
if [ "$ENCRYPTION" == "yes" ] && ([ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]); then
|
if [ "$ENCRYPTION" == true ] && ([ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]); then
|
||||||
EncryptFiles "$backupTask" "$CRYPT_STORAGE" "$GPG_RECIPIENT" true true
|
EncryptFiles "$backupTask" "$CRYPT_STORAGE" "$GPG_RECIPIENT" true true
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
Rsync "$CRYPT_STORAGE/$backupTask" "$destinationDir" true
|
Rsync "$CRYPT_STORAGE/$backupTask" "$destinationDir" true
|
||||||
else
|
else
|
||||||
Logger "backup failed." "ERROR"
|
Logger "backup failed." "ERROR"
|
||||||
fi
|
fi
|
||||||
elif [ "$ENCRYPTION" == "yes" ] && [ "$BACKUP_TYPE" == "pull" ]; then
|
elif [ "$ENCRYPTION" == true ] && [ "$BACKUP_TYPE" == "pull" ]; then
|
||||||
Rsync "$backupTask" "$destinationDir" true
|
Rsync "$backupTask" "$destinationDir" true
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
EncryptFiles "$encryptDir" "$CRYPT_STORAGE/$backupTask" "$GPG_RECIPIENT" true false
|
EncryptFiles "$encryptDir" "$CRYPT_STORAGE/$backupTask" "$GPG_RECIPIENT" true false
|
||||||
@ -4243,7 +4252,7 @@ function _RotateBackupsLocal {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
#elif [ "$REMOTE_OPERATION" == "yes" ]; then
|
#elif [ "$REMOTE_OPERATION" == true ]; then
|
||||||
cmd="cp -R \"$backup\" \"$backup.$PROGRAM.1\""
|
cmd="cp -R \"$backup\" \"$backup.$PROGRAM.1\""
|
||||||
Logger "Launching command [$cmd]." "DEBUG"
|
Logger "Launching command [$cmd]." "DEBUG"
|
||||||
eval "$cmd" &
|
eval "$cmd" &
|
||||||
@ -4276,9 +4285,9 @@ env _REMOTE_EXECUTION="true" env PROGRAM="'$PROGRAM'" env SCRIPT_PID="'$SCRIPT_P
|
|||||||
env REMOTE_FIND_CMD="'$REMOTE_FIND_CMD'" env rotateCopies="'$rotateCopies'" env backupPath="'$backupPath'" \
|
env REMOTE_FIND_CMD="'$REMOTE_FIND_CMD'" env rotateCopies="'$rotateCopies'" env backupPath="'$backupPath'" \
|
||||||
$COMMAND_SUDO' bash -s' << 'ENDSSH' > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" 2> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP"
|
$COMMAND_SUDO' bash -s' << 'ENDSSH' > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" 2> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP"
|
||||||
|
|
||||||
## allow debugging from command line with _DEBUG=yes
|
## allow debugging from command line with _DEBUG=true
|
||||||
if [ ! "$_DEBUG" == "yes" ]; then
|
if [ ! "$_DEBUG" == true ]; then
|
||||||
_DEBUG=no
|
_DEBUG=false
|
||||||
_LOGGER_VERBOSE=false
|
_LOGGER_VERBOSE=false
|
||||||
else
|
else
|
||||||
trap 'TrapError ${LINENO} $?' ERR
|
trap 'TrapError ${LINENO} $?' ERR
|
||||||
@ -4348,19 +4357,19 @@ function RemoteLogger {
|
|||||||
|
|
||||||
if [ "$level" == "CRITICAL" ]; then
|
if [ "$level" == "CRITICAL" ]; then
|
||||||
_Logger "" "$prefix\e[1;33;41m$value\e[0m" true
|
_Logger "" "$prefix\e[1;33;41m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
elif [ "$level" == "ERROR" ]; then
|
elif [ "$level" == "ERROR" ]; then
|
||||||
_Logger "" "$prefix\e[31m$value\e[0m" true
|
_Logger "" "$prefix\e[31m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
elif [ "$level" == "WARN" ]; then
|
elif [ "$level" == "WARN" ]; then
|
||||||
_Logger "" "$prefix\e[33m$value\e[0m" true
|
_Logger "" "$prefix\e[33m$value\e[0m" true
|
||||||
if [ $_DEBUG == "yes" ]; then
|
if [ $_DEBUG == true ]; then
|
||||||
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
@ -4378,7 +4387,7 @@ function RemoteLogger {
|
|||||||
_Logger "" "$prefix$value"
|
_Logger "" "$prefix$value"
|
||||||
return
|
return
|
||||||
elif [ "$level" == "DEBUG" ]; then
|
elif [ "$level" == "DEBUG" ]; then
|
||||||
if [ "$_DEBUG" == "yes" ]; then
|
if [ "$_DEBUG" == true ]; then
|
||||||
_Logger "" "$prefix$value"
|
_Logger "" "$prefix$value"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -4434,7 +4443,7 @@ function _RotateBackupsRemoteSSH {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
#elif [ "$REMOTE_OPERATION" == "yes" ]; then
|
#elif [ "$REMOTE_OPERATION" == true ]; then
|
||||||
cmd="cp -R \"$backup\" \"$backup.$PROGRAM.1\""
|
cmd="cp -R \"$backup\" \"$backup.$PROGRAM.1\""
|
||||||
RemoteLogger "Launching command [$cmd]." "DEBUG"
|
RemoteLogger "Launching command [$cmd]." "DEBUG"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
@ -4494,7 +4503,7 @@ function Init {
|
|||||||
|
|
||||||
## Test if target dir is a ssh uri, and if yes, break it down it its values
|
## Test if target dir is a ssh uri, and if yes, break it down it its values
|
||||||
if [ "${REMOTE_SYSTEM_URI:0:6}" == "ssh://" ] && [ "$BACKUP_TYPE" != "local" ]; then
|
if [ "${REMOTE_SYSTEM_URI:0:6}" == "ssh://" ] && [ "$BACKUP_TYPE" != "local" ]; then
|
||||||
REMOTE_OPERATION="yes"
|
REMOTE_OPERATION=true
|
||||||
|
|
||||||
# remove leadng 'ssh://'
|
# remove leadng 'ssh://'
|
||||||
uri=${REMOTE_SYSTEM_URI#ssh://*}
|
uri=${REMOTE_SYSTEM_URI#ssh://*}
|
||||||
@ -4531,7 +4540,7 @@ function Init {
|
|||||||
RSYNC_TYPE_ARGS=$RSYNC_TYPE_ARGS" -i"
|
RSYNC_TYPE_ARGS=$RSYNC_TYPE_ARGS" -i"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$DELETE_VANISHED_FILES" == "yes" ]; then
|
if [ "$DELETE_VANISHED_FILES" == true ]; then
|
||||||
RSYNC_TYPE_ARGS=$RSYNC_TYPE_ARGS" --delete"
|
RSYNC_TYPE_ARGS=$RSYNC_TYPE_ARGS" --delete"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -4545,12 +4554,12 @@ function Init {
|
|||||||
|
|
||||||
function Main {
|
function Main {
|
||||||
|
|
||||||
if [ "$SQL_BACKUP" != "no" ] && [ $CAN_BACKUP_SQL == true ]; then
|
if [ "$SQL_BACKUP" != false ] && [ $CAN_BACKUP_SQL == true ]; then
|
||||||
ListDatabases
|
ListDatabases
|
||||||
fi
|
fi
|
||||||
if [ "$FILE_BACKUP" != "no" ] && [ $CAN_BACKUP_FILES == true ]; then
|
if [ "$FILE_BACKUP" != false ] && [ $CAN_BACKUP_FILES == true ]; then
|
||||||
ListRecursiveBackupDirectories
|
ListRecursiveBackupDirectories
|
||||||
if [ "$GET_BACKUP_SIZE" != "no" ]; then
|
if [ "$GET_BACKUP_SIZE" != false ]; then
|
||||||
GetDirectoriesSize
|
GetDirectoriesSize
|
||||||
else
|
else
|
||||||
TOTAL_FILES_SIZE=-1
|
TOTAL_FILES_SIZE=-1
|
||||||
@ -4564,21 +4573,21 @@ function Main {
|
|||||||
SSH_PASSWORD_FILE="${SSH_PASSWORD_FILE/#\~/$HOME}"
|
SSH_PASSWORD_FILE="${SSH_PASSWORD_FILE/#\~/$HOME}"
|
||||||
ENCRYPT_PUBKEY="${ENCRYPT_PUBKEY/#\~/$HOME}"
|
ENCRYPT_PUBKEY="${ENCRYPT_PUBKEY/#\~/$HOME}"
|
||||||
|
|
||||||
if [ "$CREATE_DIRS" != "no" ]; then
|
if [ "$CREATE_DIRS" != false ]; then
|
||||||
CreateStorageDirectories
|
CreateStorageDirectories
|
||||||
fi
|
fi
|
||||||
CheckDiskSpace
|
CheckDiskSpace
|
||||||
|
|
||||||
# Actual backup process
|
# Actual backup process
|
||||||
if [ "$SQL_BACKUP" != "no" ] && [ $CAN_BACKUP_SQL == true ]; then
|
if [ "$SQL_BACKUP" != false ] && [ $CAN_BACKUP_SQL == true ]; then
|
||||||
if [ $_DRYRUN == false ] && [ "$ROTATE_SQL_BACKUPS" == "yes" ]; then
|
if [ $_DRYRUN == false ] && [ "$ROTATE_SQL_BACKUPS" == true ]; then
|
||||||
RotateBackups "$SQL_STORAGE" "$ROTATE_SQL_COPIES"
|
RotateBackups "$SQL_STORAGE" "$ROTATE_SQL_COPIES"
|
||||||
fi
|
fi
|
||||||
BackupDatabases
|
BackupDatabases
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$FILE_BACKUP" != "no" ] && [ $CAN_BACKUP_FILES == true ]; then
|
if [ "$FILE_BACKUP" != false ] && [ $CAN_BACKUP_FILES == true ]; then
|
||||||
if [ $_DRYRUN == false ] && [ "$ROTATE_FILE_BACKUPS" == "yes" ]; then
|
if [ $_DRYRUN == false ] && [ "$ROTATE_FILE_BACKUPS" == true ]; then
|
||||||
RotateBackups "$FILE_STORAGE" "$ROTATE_FILE_COPIES"
|
RotateBackups "$FILE_STORAGE" "$ROTATE_FILE_COPIES"
|
||||||
fi
|
fi
|
||||||
## Add Rsync include / exclude patterns
|
## Add Rsync include / exclude patterns
|
||||||
@ -4590,7 +4599,7 @@ function Main {
|
|||||||
function Usage {
|
function Usage {
|
||||||
|
|
||||||
|
|
||||||
if [ "$IS_STABLE" != "yes" ]; then
|
if [ "$IS_STABLE" != true ]; then
|
||||||
echo -e "\e[93mThis is an unstable dev build. Please use with caution.\e[0m"
|
echo -e "\e[93mThis is an unstable dev build. Please use with caution.\e[0m"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -4748,6 +4757,9 @@ else
|
|||||||
LOG_FILE="$LOGFILE"
|
LOG_FILE="$LOGFILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# v2.3 config syntax compatibility
|
||||||
|
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
|
||||||
@ -4764,18 +4776,18 @@ if [ $no_maxtime == true ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $partial_transfers == true ]; then
|
if [ $partial_transfers == true ]; then
|
||||||
PARTIAL="yes"
|
PARTIAL=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $delete_vanished == true ]; then
|
if [ $delete_vanished == true ]; then
|
||||||
DELETE_VANISHED_FILES="yes"
|
DELETE_VANISHED_FILES=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $dont_get_backup_size == true ]; then
|
if [ $dont_get_backup_size == true ]; then
|
||||||
GET_BACKUP_SIZE="no"
|
GET_BACKUP_SIZE=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$IS_STABLE" != "yes" ]; then
|
if [ "$IS_STABLE" != true ]; then
|
||||||
Logger "This is an unstable dev build [$PROGRAM_BUILD]. Please use with caution." "WARN"
|
Logger "This is an unstable dev build [$PROGRAM_BUILD]. Please use with caution." "WARN"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user