1
0
mirror of https://github.com/deajan/obackup.git synced 2026-02-12 18:10:56 +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

@@ -6,7 +6,7 @@ PROGRAM="obackup"
AUTHOR="(L) 2013-2015 by Orsiris de Jong"
CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr"
PROGRAM_VERSION=2.0-pre
PROGRAM_BUILD=2015111901
PROGRAM_BUILD=2015112002
IS_STABLE=no
source "./ofunctions.sh"
@@ -112,6 +112,13 @@ function CheckCurrentConfig {
eval "$test"
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)
}
@@ -499,7 +506,7 @@ function GetDiskSpaceLocal {
local path_to_check="${1}"
__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
# 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
@@ -512,7 +519,7 @@ function GetDiskSpaceLocal {
DRIVE=$(cat $RUN_DIR/$PROGRAM.$FUNCNAME.$SCRIPT_PID | tail -1 | awk '{print $1}')
fi
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
fi
}
@@ -522,7 +529,7 @@ function GetDiskSpaceRemote {
local path_to_check="${1}"
__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"
eval "$cmd" &
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
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
local file_storage_path="$FILE_STORAGE"
fi
@@ -766,17 +773,17 @@ function Rsync {
# Creating subdirectories because rsync cannot handle multiple subdirectory creation
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"
elif [ "$BACKUP_TYPE" == "pull" ]; then
_CreateDirectoryLocal "$file_storage_path/$backup_directory"
_CreateDirectoryLocal "$file_storage_path"
CheckConnectivity3rdPartyHosts
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"
elif [ "$BACKUP_TYPE" == "push" ]; then
CheckConnectivity3rdPartyHosts
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"
fi