Fixes issue #59 - script didn't work when source set to '/'

This commit is contained in:
Laurent Cozic
2016-11-29 12:28:10 +00:00
committed by Laurent Cozic
parent 1880478bc5
commit 756b03bc32
+15 -6
View File
@@ -148,8 +148,8 @@ while :; do
;; ;;
--) --)
shift shift
SRC_FOLDER="${1%/}" SRC_FOLDER="$1"
DEST_FOLDER="${2%/}" DEST_FOLDER="$2"
EXCLUSION_FILE="$3" EXCLUSION_FILE="$3"
break break
;; ;;
@@ -160,8 +160,8 @@ while :; do
exit 1 exit 1
;; ;;
*) *)
SRC_FOLDER="${1%/}" SRC_FOLDER="$1"
DEST_FOLDER="${2%/}" DEST_FOLDER="$2"
EXCLUSION_FILE="$3" EXCLUSION_FILE="$3"
break break
esac esac
@@ -175,6 +175,15 @@ if [[ -z "$SRC_FOLDER" || -z "$DEST_FOLDER" ]]; then
exit 1 exit 1
fi fi
# Strips off last slash. Note that it means the root folder "/"
# will be represented as an empty string "", which is fine
# with the current script (since a "/" is added when needed)
# but still something to keep in mind.
# Don't think it would with DEST_FOLDER set to "/" though,
# but there's probably not a use case for this anyway.
SRC_FOLDER="${SRC_FOLDER%/}"
DEST_FOLDER="${DEST_FOLDER%/}"
fn_parse_ssh fn_parse_ssh
if [ -n "$SSH_DEST_FOLDER" ]; then if [ -n "$SSH_DEST_FOLDER" ]; then
@@ -328,8 +337,8 @@ while : ; do
LOG_FILE="$PROFILE_FOLDER/$(date +"%Y-%m-%d-%H%M%S").log" LOG_FILE="$PROFILE_FOLDER/$(date +"%Y-%m-%d-%H%M%S").log"
fn_log_info "Starting backup..." fn_log_info "Starting backup..."
fn_log_info "From: $SRC_FOLDER" fn_log_info "From: $SRC_FOLDER/"
fn_log_info "To: $SSH_FOLDER_PREFIX$DEST" fn_log_info "To: $SSH_FOLDER_PREFIX$DEST/"
CMD="rsync" CMD="rsync"
if [ -n "$SSH_CMD" ]; then if [ -n "$SSH_CMD" ]; then