1
0
mirror of https://github.com/deajan/obackup.git synced 2024-12-04 20:53:41 +01:00

Fixed bogus directory creation in some backup cases

This commit is contained in:
deajan 2015-11-21 13:22:14 +01:00
parent 61a70b1ba5
commit 954606b8ba
4 changed files with 50 additions and 24 deletions

View File

@ -24,6 +24,7 @@ README: FreeBSD execution needs mailer (not found), sudo missing, bash needed, s
- Added some automatic checks in code, for _DEBUG mode (and _PARANOIA_DEBUG now) - Added some automatic checks in code, for _DEBUG mode (and _PARANOIA_DEBUG now)
- Improved Logging - Improved Logging
- Updated obackup to be fully compliant with coding style - Updated obackup to be fully compliant with coding style
- Fixed creation of bogus subdirectories in some cases
- A long list of minor improvements - A long list of minor improvements
v0-1.x - Jan 2013 - Oct 2015 v0-1.x - Jan 2013 - Oct 2015

View File

@ -6,7 +6,7 @@ PROGRAM="obackup"
AUTHOR="(L) 2013-2015 by Orsiris de Jong" AUTHOR="(L) 2013-2015 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.0-pre PROGRAM_VERSION=2.0-pre
PROGRAM_BUILD=2015111901 PROGRAM_BUILD=2015112002
IS_STABLE=no IS_STABLE=no
FUNC_BUILD=2015111901 FUNC_BUILD=2015111901
@ -85,6 +85,7 @@ function Dummy {
sleep .1 sleep .1
} }
#__FUNC:Logger
function _Logger { function _Logger {
local svalue="${1}" # What to log to screen local svalue="${1}" # What to log to screen
local lvalue="${2:-$svalue}" # What to log to logfile, defaults to screen value local lvalue="${2:-$svalue}" # What to log to logfile, defaults to screen value
@ -137,6 +138,7 @@ function Logger {
_Logger "$prefix$value" _Logger "$prefix$value"
fi fi
} }
#__ENDFUNC
# Portable child (and grandchild) kill function tester under Linux, BSD and MacOS X # Portable child (and grandchild) kill function tester under Linux, BSD and MacOS X
function KillChilds { function KillChilds {
@ -998,6 +1000,13 @@ function CheckCurrentConfig {
eval "$test" eval "$test"
done done
if [ "$FILE_BACKUP" == "yes" ]; then
if [ "$DIRECTORY_LIST" == "" ] && [ "$RECURSIVE_DIRECTORY_LIST" == "" ]; then
Logger "No directories specified in config file, no files to backup." "ERROR"
CAN_BACKUP_FILES=0
fi
fi
#TODO-v2.1: Add runtime variable tests (RSYNC_ARGS etc) #TODO-v2.1: Add runtime variable tests (RSYNC_ARGS etc)
} }
@ -1385,7 +1394,7 @@ function GetDiskSpaceLocal {
local path_to_check="${1}" local path_to_check="${1}"
__CheckArguments 1 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 1 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG
if [ -w "$path_to_check" ]; then if [ -d "$path_to_check" ]; then
# Not elegant solution to make df silent on errors # Not elegant solution to make df silent on errors
# No sudo on local commands, assuming you should have all the necesarry rights to check backup directories sizes # No sudo on local commands, assuming you should have all the necesarry rights to check backup directories sizes
df -P "$path_to_check" > "$RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID" 2>&1 df -P "$path_to_check" > "$RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID" 2>&1
@ -1398,7 +1407,7 @@ function GetDiskSpaceLocal {
DRIVE=$(cat $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID | tail -1 | awk '{print $1}') DRIVE=$(cat $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID | tail -1 | awk '{print $1}')
fi fi
else else
Logger "Storage path [$path_to_check] does not exist or cannot write to it." "CRITICAL" Logger "Storage path [$path_to_check] does not exist." "CRITICAL"
return 1 return 1
fi fi
} }
@ -1408,7 +1417,7 @@ function GetDiskSpaceRemote {
local path_to_check="${1}" local path_to_check="${1}"
__CheckArguments 1 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 1 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG
cmd=$SSH_CMD' "if [ -w \"'$path_to_check'\" ]; then '$COMMAND_SUDO' df -P \"'$path_to_check'\"; else exit 1; fi" > "'$RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID'" 2>&1' cmd=$SSH_CMD' "if [ -d \"'$path_to_check'\" ]; then '$COMMAND_SUDO' df -P \"'$path_to_check'\"; else exit 1; fi" > "'$RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID'" 2>&1'
Logger "cmd: $cmd" "DEBUG" Logger "cmd: $cmd" "DEBUG"
eval "$cmd" & eval "$cmd" &
WaitForTaskCompletion $! $SOFT_MAX_EXEC_TIME_DB_TASK $HARD_MAX_EXEC_TIME_DB_TASK $FUNCNAME WaitForTaskCompletion $! $SOFT_MAX_EXEC_TIME_DB_TASK $HARD_MAX_EXEC_TIME_DB_TASK $FUNCNAME
@ -1637,7 +1646,7 @@ function Rsync {
__CheckArguments 2 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 2 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG
if [ "$KEEP_ABSOLUTE_PATHS" == "yes" ]; then if [ "$KEEP_ABSOLUTE_PATHS" == "yes" ]; then
local file_storage_path="$(dirname $FILE_STORAGE$backup_directory)" local file_storage_path="$(dirname $FILE_STORAGE/${backup_directory#/})"
else else
local file_storage_path="$FILE_STORAGE" local file_storage_path="$FILE_STORAGE"
fi fi
@ -1652,17 +1661,17 @@ function Rsync {
# Creating subdirectories because rsync cannot handle multiple subdirectory creation # Creating subdirectories because rsync cannot handle multiple subdirectory creation
if [ "$BACKUP_TYPE" == "local" ]; then if [ "$BACKUP_TYPE" == "local" ]; then
_CreateDirectoryLocal "$file_storage_path/$backup_directory" _CreateDirectoryLocal "$file_storage_path"
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) $RSYNC_ARGS $RSYNC_NO_RECURSE_ARGS --stats $RSYNC_DELETE $RSYNC_EXCLUDE --rsync-path=\"$RSYNC_PATH\" \"$backup_directory\" \"$file_storage_path\" > $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID 2>&1" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) $RSYNC_ARGS $RSYNC_NO_RECURSE_ARGS --stats $RSYNC_DELETE $RSYNC_EXCLUDE --rsync-path=\"$RSYNC_PATH\" \"$backup_directory\" \"$file_storage_path\" > $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID 2>&1"
elif [ "$BACKUP_TYPE" == "pull" ]; then elif [ "$BACKUP_TYPE" == "pull" ]; then
_CreateDirectoryLocal "$file_storage_path/$backup_directory" _CreateDirectoryLocal "$file_storage_path"
CheckConnectivity3rdPartyHosts CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost CheckConnectivityRemoteHost
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) $RSYNC_ARGS $RSYNC_NO_RECURSE_ARGS --stats $RSYNC_DELETE $RSYNC_EXCLUDE --rsync-path=\"$RSYNC_PATH\" -e \"$RSYNC_SSH_CMD\" \"$REMOTE_USER@$REMOTE_HOST:$backup_directory\" \"$file_storage_path\" > $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID 2>&1" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) $RSYNC_ARGS $RSYNC_NO_RECURSE_ARGS --stats $RSYNC_DELETE $RSYNC_EXCLUDE --rsync-path=\"$RSYNC_PATH\" -e \"$RSYNC_SSH_CMD\" \"$REMOTE_USER@$REMOTE_HOST:$backup_directory\" \"$file_storage_path\" > $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID 2>&1"
elif [ "$BACKUP_TYPE" == "push" ]; then elif [ "$BACKUP_TYPE" == "push" ]; then
CheckConnectivity3rdPartyHosts CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost CheckConnectivityRemoteHost
_CreateDirectoryRemote "$file_storage_path/$backup_directory" _CreateDirectoryRemote "$file_storage_path"
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) $RSYNC_ARGS $RSYNC_NO_RECURSE_ARGS --stats $RSYNC_DELETE $RSYNC_EXCLUDE --rsync-path=\"$RSYNC_PATH\" -e \"$RSYNC_SSH_CMD\" \"$backup_directory\" \"$REMOTE_USER@$REMOTE_HOST:$file_storage_path\" > $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID 2>&1" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) $RSYNC_ARGS $RSYNC_NO_RECURSE_ARGS --stats $RSYNC_DELETE $RSYNC_EXCLUDE --rsync-path=\"$RSYNC_PATH\" -e \"$RSYNC_SSH_CMD\" \"$backup_directory\" \"$REMOTE_USER@$REMOTE_HOST:$file_storage_path\" > $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID 2>&1"
fi fi

View File

@ -6,7 +6,7 @@ PROGRAM="obackup"
AUTHOR="(L) 2013-2015 by Orsiris de Jong" AUTHOR="(L) 2013-2015 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.0-pre PROGRAM_VERSION=2.0-pre
PROGRAM_BUILD=2015111901 PROGRAM_BUILD=2015112002
IS_STABLE=no IS_STABLE=no
source "./ofunctions.sh" source "./ofunctions.sh"
@ -112,6 +112,13 @@ function CheckCurrentConfig {
eval "$test" eval "$test"
done done
if [ "$FILE_BACKUP" == "yes" ]; then
if [ "$DIRECTORY_LIST" == "" ] && [ "$RECURSIVE_DIRECTORY_LIST" == "" ]; then
Logger "No directories specified in config file, no files to backup." "ERROR"
CAN_BACKUP_FILES=0
fi
fi
#TODO-v2.1: Add runtime variable tests (RSYNC_ARGS etc) #TODO-v2.1: Add runtime variable tests (RSYNC_ARGS etc)
} }
@ -499,7 +506,7 @@ function GetDiskSpaceLocal {
local path_to_check="${1}" local path_to_check="${1}"
__CheckArguments 1 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 1 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG
if [ -w "$path_to_check" ]; then if [ -d "$path_to_check" ]; then
# Not elegant solution to make df silent on errors # Not elegant solution to make df silent on errors
# No sudo on local commands, assuming you should have all the necesarry rights to check backup directories sizes # No sudo on local commands, assuming you should have all the necesarry rights to check backup directories sizes
df -P "$path_to_check" > "$RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID" 2>&1 df -P "$path_to_check" > "$RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID" 2>&1
@ -512,7 +519,7 @@ function GetDiskSpaceLocal {
DRIVE=$(cat $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID | tail -1 | awk '{print $1}') DRIVE=$(cat $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID | tail -1 | awk '{print $1}')
fi fi
else else
Logger "Storage path [$path_to_check] does not exist or cannot write to it." "CRITICAL" Logger "Storage path [$path_to_check] does not exist." "CRITICAL"
return 1 return 1
fi fi
} }
@ -522,7 +529,7 @@ function GetDiskSpaceRemote {
local path_to_check="${1}" local path_to_check="${1}"
__CheckArguments 1 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 1 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG
cmd=$SSH_CMD' "if [ -w \"'$path_to_check'\" ]; then '$COMMAND_SUDO' df -P \"'$path_to_check'\"; else exit 1; fi" > "'$RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID'" 2>&1' cmd=$SSH_CMD' "if [ -d \"'$path_to_check'\" ]; then '$COMMAND_SUDO' df -P \"'$path_to_check'\"; else exit 1; fi" > "'$RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID'" 2>&1'
Logger "cmd: $cmd" "DEBUG" Logger "cmd: $cmd" "DEBUG"
eval "$cmd" & eval "$cmd" &
WaitForTaskCompletion $! $SOFT_MAX_EXEC_TIME_DB_TASK $HARD_MAX_EXEC_TIME_DB_TASK $FUNCNAME WaitForTaskCompletion $! $SOFT_MAX_EXEC_TIME_DB_TASK $HARD_MAX_EXEC_TIME_DB_TASK $FUNCNAME
@ -751,7 +758,7 @@ function Rsync {
__CheckArguments 2 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 2 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG
if [ "$KEEP_ABSOLUTE_PATHS" == "yes" ]; then if [ "$KEEP_ABSOLUTE_PATHS" == "yes" ]; then
local file_storage_path="$(dirname $FILE_STORAGE$backup_directory)" local file_storage_path="$(dirname $FILE_STORAGE/${backup_directory#/})"
else else
local file_storage_path="$FILE_STORAGE" local file_storage_path="$FILE_STORAGE"
fi fi
@ -766,17 +773,17 @@ function Rsync {
# Creating subdirectories because rsync cannot handle multiple subdirectory creation # Creating subdirectories because rsync cannot handle multiple subdirectory creation
if [ "$BACKUP_TYPE" == "local" ]; then if [ "$BACKUP_TYPE" == "local" ]; then
_CreateDirectoryLocal "$file_storage_path/$backup_directory" _CreateDirectoryLocal "$file_storage_path"
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) $RSYNC_ARGS $RSYNC_NO_RECURSE_ARGS --stats $RSYNC_DELETE $RSYNC_EXCLUDE --rsync-path=\"$RSYNC_PATH\" \"$backup_directory\" \"$file_storage_path\" > $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID 2>&1" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) $RSYNC_ARGS $RSYNC_NO_RECURSE_ARGS --stats $RSYNC_DELETE $RSYNC_EXCLUDE --rsync-path=\"$RSYNC_PATH\" \"$backup_directory\" \"$file_storage_path\" > $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID 2>&1"
elif [ "$BACKUP_TYPE" == "pull" ]; then elif [ "$BACKUP_TYPE" == "pull" ]; then
_CreateDirectoryLocal "$file_storage_path/$backup_directory" _CreateDirectoryLocal "$file_storage_path"
CheckConnectivity3rdPartyHosts CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost CheckConnectivityRemoteHost
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) $RSYNC_ARGS $RSYNC_NO_RECURSE_ARGS --stats $RSYNC_DELETE $RSYNC_EXCLUDE --rsync-path=\"$RSYNC_PATH\" -e \"$RSYNC_SSH_CMD\" \"$REMOTE_USER@$REMOTE_HOST:$backup_directory\" \"$file_storage_path\" > $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID 2>&1" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) $RSYNC_ARGS $RSYNC_NO_RECURSE_ARGS --stats $RSYNC_DELETE $RSYNC_EXCLUDE --rsync-path=\"$RSYNC_PATH\" -e \"$RSYNC_SSH_CMD\" \"$REMOTE_USER@$REMOTE_HOST:$backup_directory\" \"$file_storage_path\" > $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID 2>&1"
elif [ "$BACKUP_TYPE" == "push" ]; then elif [ "$BACKUP_TYPE" == "push" ]; then
CheckConnectivity3rdPartyHosts CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost CheckConnectivityRemoteHost
_CreateDirectoryRemote "$file_storage_path/$backup_directory" _CreateDirectoryRemote "$file_storage_path"
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) $RSYNC_ARGS $RSYNC_NO_RECURSE_ARGS --stats $RSYNC_DELETE $RSYNC_EXCLUDE --rsync-path=\"$RSYNC_PATH\" -e \"$RSYNC_SSH_CMD\" \"$backup_directory\" \"$REMOTE_USER@$REMOTE_HOST:$file_storage_path\" > $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID 2>&1" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) $RSYNC_ARGS $RSYNC_NO_RECURSE_ARGS --stats $RSYNC_DELETE $RSYNC_EXCLUDE --rsync-path=\"$RSYNC_PATH\" -e \"$RSYNC_SSH_CMD\" \"$backup_directory\" \"$REMOTE_USER@$REMOTE_HOST:$file_storage_path\" > $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID 2>&1"
fi fi

View File

@ -6,7 +6,7 @@ PROGRAM="obackup"
AUTHOR="(L) 2013-2015 by Orsiris de Jong" AUTHOR="(L) 2013-2015 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.0-pre PROGRAM_VERSION=2.0-pre
PROGRAM_BUILD=2015111901 PROGRAM_BUILD=2015112002
IS_STABLE=no IS_STABLE=no
FUNC_BUILD=2015111901 FUNC_BUILD=2015111901
@ -80,6 +80,7 @@ function Dummy {
sleep .1 sleep .1
} }
#__FUNC:Logger
function _Logger { function _Logger {
local svalue="${1}" # What to log to screen local svalue="${1}" # What to log to screen
local lvalue="${2:-$svalue}" # What to log to logfile, defaults to screen value local lvalue="${2:-$svalue}" # What to log to logfile, defaults to screen value
@ -127,6 +128,7 @@ function Logger {
_Logger "$prefix$value" _Logger "$prefix$value"
fi fi
} }
#__ENDFUNC
# Portable child (and grandchild) kill function tester under Linux, BSD and MacOS X # Portable child (and grandchild) kill function tester under Linux, BSD and MacOS X
function KillChilds { function KillChilds {
@ -895,6 +897,13 @@ function CheckCurrentConfig {
eval "$test" eval "$test"
done done
if [ "$FILE_BACKUP" == "yes" ]; then
if [ "$DIRECTORY_LIST" == "" ] && [ "$RECURSIVE_DIRECTORY_LIST" == "" ]; then
Logger "No directories specified in config file, no files to backup." "ERROR"
CAN_BACKUP_FILES=0
fi
fi
#TODO-v2.1: Add runtime variable tests (RSYNC_ARGS etc) #TODO-v2.1: Add runtime variable tests (RSYNC_ARGS etc)
} }
@ -1269,7 +1278,7 @@ function GetDiskSpaceLocal {
# GLOBAL VARIABLE DRIVE to pass variable to parent function # GLOBAL VARIABLE DRIVE to pass variable to parent function
local path_to_check="${1}" local path_to_check="${1}"
if [ -w "$path_to_check" ]; then if [ -d "$path_to_check" ]; then
# Not elegant solution to make df silent on errors # Not elegant solution to make df silent on errors
# No sudo on local commands, assuming you should have all the necesarry rights to check backup directories sizes # No sudo on local commands, assuming you should have all the necesarry rights to check backup directories sizes
df -P "$path_to_check" > "$RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID" 2>&1 df -P "$path_to_check" > "$RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID" 2>&1
@ -1282,7 +1291,7 @@ function GetDiskSpaceLocal {
DRIVE=$(cat $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID | tail -1 | awk '{print $1}') DRIVE=$(cat $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID | tail -1 | awk '{print $1}')
fi fi
else else
Logger "Storage path [$path_to_check] does not exist or cannot write to it." "CRITICAL" Logger "Storage path [$path_to_check] does not exist." "CRITICAL"
return 1 return 1
fi fi
} }
@ -1291,7 +1300,7 @@ function GetDiskSpaceRemote {
# USE GLOBAL VARIABLE DISK_SPACE to pass variable to parent function # USE GLOBAL VARIABLE DISK_SPACE to pass variable to parent function
local path_to_check="${1}" local path_to_check="${1}"
cmd=$SSH_CMD' "if [ -w \"'$path_to_check'\" ]; then '$COMMAND_SUDO' df -P \"'$path_to_check'\"; else exit 1; fi" > "'$RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID'" 2>&1' cmd=$SSH_CMD' "if [ -d \"'$path_to_check'\" ]; then '$COMMAND_SUDO' df -P \"'$path_to_check'\"; else exit 1; fi" > "'$RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID'" 2>&1'
Logger "cmd: $cmd" "DEBUG" Logger "cmd: $cmd" "DEBUG"
eval "$cmd" & eval "$cmd" &
WaitForTaskCompletion $! $SOFT_MAX_EXEC_TIME_DB_TASK $HARD_MAX_EXEC_TIME_DB_TASK $FUNCNAME WaitForTaskCompletion $! $SOFT_MAX_EXEC_TIME_DB_TASK $HARD_MAX_EXEC_TIME_DB_TASK $FUNCNAME
@ -1513,7 +1522,7 @@ function Rsync {
if [ "$KEEP_ABSOLUTE_PATHS" == "yes" ]; then if [ "$KEEP_ABSOLUTE_PATHS" == "yes" ]; then
local file_storage_path="$(dirname $FILE_STORAGE$backup_directory)" local file_storage_path="$(dirname $FILE_STORAGE/${backup_directory#/})"
else else
local file_storage_path="$FILE_STORAGE" local file_storage_path="$FILE_STORAGE"
fi fi
@ -1528,17 +1537,17 @@ function Rsync {
# Creating subdirectories because rsync cannot handle multiple subdirectory creation # Creating subdirectories because rsync cannot handle multiple subdirectory creation
if [ "$BACKUP_TYPE" == "local" ]; then if [ "$BACKUP_TYPE" == "local" ]; then
_CreateDirectoryLocal "$file_storage_path/$backup_directory" _CreateDirectoryLocal "$file_storage_path"
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) $RSYNC_ARGS $RSYNC_NO_RECURSE_ARGS --stats $RSYNC_DELETE $RSYNC_EXCLUDE --rsync-path=\"$RSYNC_PATH\" \"$backup_directory\" \"$file_storage_path\" > $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID 2>&1" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) $RSYNC_ARGS $RSYNC_NO_RECURSE_ARGS --stats $RSYNC_DELETE $RSYNC_EXCLUDE --rsync-path=\"$RSYNC_PATH\" \"$backup_directory\" \"$file_storage_path\" > $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID 2>&1"
elif [ "$BACKUP_TYPE" == "pull" ]; then elif [ "$BACKUP_TYPE" == "pull" ]; then
_CreateDirectoryLocal "$file_storage_path/$backup_directory" _CreateDirectoryLocal "$file_storage_path"
CheckConnectivity3rdPartyHosts CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost CheckConnectivityRemoteHost
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) $RSYNC_ARGS $RSYNC_NO_RECURSE_ARGS --stats $RSYNC_DELETE $RSYNC_EXCLUDE --rsync-path=\"$RSYNC_PATH\" -e \"$RSYNC_SSH_CMD\" \"$REMOTE_USER@$REMOTE_HOST:$backup_directory\" \"$file_storage_path\" > $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID 2>&1" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) $RSYNC_ARGS $RSYNC_NO_RECURSE_ARGS --stats $RSYNC_DELETE $RSYNC_EXCLUDE --rsync-path=\"$RSYNC_PATH\" -e \"$RSYNC_SSH_CMD\" \"$REMOTE_USER@$REMOTE_HOST:$backup_directory\" \"$file_storage_path\" > $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID 2>&1"
elif [ "$BACKUP_TYPE" == "push" ]; then elif [ "$BACKUP_TYPE" == "push" ]; then
CheckConnectivity3rdPartyHosts CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost CheckConnectivityRemoteHost
_CreateDirectoryRemote "$file_storage_path/$backup_directory" _CreateDirectoryRemote "$file_storage_path"
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) $RSYNC_ARGS $RSYNC_NO_RECURSE_ARGS --stats $RSYNC_DELETE $RSYNC_EXCLUDE --rsync-path=\"$RSYNC_PATH\" -e \"$RSYNC_SSH_CMD\" \"$backup_directory\" \"$REMOTE_USER@$REMOTE_HOST:$file_storage_path\" > $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID 2>&1" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) $RSYNC_ARGS $RSYNC_NO_RECURSE_ARGS --stats $RSYNC_DELETE $RSYNC_EXCLUDE --rsync-path=\"$RSYNC_PATH\" -e \"$RSYNC_SSH_CMD\" \"$backup_directory\" \"$REMOTE_USER@$REMOTE_HOST:$file_storage_path\" > $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID 2>&1"
fi fi