summaryrefslogtreecommitdiff
path: root/rsync_tmbackup.sh
diff options
context:
space:
mode:
authorLaurent Cozic <laurent@cozic.net>2016-11-29 12:28:10 +0000
committerLaurent Cozic <laurent@cohortglobal.com>2016-11-29 12:29:07 +0000
commit756b03bc32476e3ef4cc01ec52639383a51cb8fe (patch)
tree4922d1289b784551ece244facbef6fb633c69166 /rsync_tmbackup.sh
parent1880478bc5eaad53d889cbb8dd5ca2b7cddca06a (diff)
Fixes issue #59 - script didn't work when source set to '/'
Diffstat (limited to 'rsync_tmbackup.sh')
-rwxr-xr-xrsync_tmbackup.sh21
1 files changed, 15 insertions, 6 deletions
diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh
index f5569c9..48b3ca5 100755
--- a/rsync_tmbackup.sh
+++ b/rsync_tmbackup.sh
@@ -148,8 +148,8 @@ while :; do
;;
--)
shift
- SRC_FOLDER="${1%/}"
- DEST_FOLDER="${2%/}"
+ SRC_FOLDER="$1"
+ DEST_FOLDER="$2"
EXCLUSION_FILE="$3"
break
;;
@@ -160,8 +160,8 @@ while :; do
exit 1
;;
*)
- SRC_FOLDER="${1%/}"
- DEST_FOLDER="${2%/}"
+ SRC_FOLDER="$1"
+ DEST_FOLDER="$2"
EXCLUSION_FILE="$3"
break
esac
@@ -175,6 +175,15 @@ if [[ -z "$SRC_FOLDER" || -z "$DEST_FOLDER" ]]; then
exit 1
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
if [ -n "$SSH_DEST_FOLDER" ]; then
@@ -328,8 +337,8 @@ while : ; do
LOG_FILE="$PROFILE_FOLDER/$(date +"%Y-%m-%d-%H%M%S").log"
fn_log_info "Starting backup..."
- fn_log_info "From: $SRC_FOLDER"
- fn_log_info "To: $SSH_FOLDER_PREFIX$DEST"
+ fn_log_info "From: $SRC_FOLDER/"
+ fn_log_info "To: $SSH_FOLDER_PREFIX$DEST/"
CMD="rsync"
if [ -n "$SSH_CMD" ]; then