summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Cozic <laurent@pogopixels.com>2016-02-03 17:22:48 +0100
committerLaurent Cozic <laurent@pogopixels.com>2016-02-03 17:22:48 +0100
commit7585aae16c1beb7356363701c9ec0165779dd8bc (patch)
treed574d3c77970864fab151726c0a4fadb9007825b
parent9c36702657c1e24c7fbcd8397f6b28929b1b4306 (diff)
parenta8504cbf4cfee7978b57277ff0c1f8735d27c16d (diff)
Merge pull request #32 from bhuvi8/master
display usage info if required args not passed
-rw-r--r--.gitignore3
-rwxr-xr-xrsync_tmbackup.sh8
2 files changed, 10 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index e8d64cc..aa54d41 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
.idea
-test.sh \ No newline at end of file
+test.sh
+*~
diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh
index 0992d3c..2d67694 100755
--- a/rsync_tmbackup.sh
+++ b/rsync_tmbackup.sh
@@ -31,6 +31,9 @@ trap 'fn_terminate_script' SIGINT
# -----------------------------------------------------------------------------
# Small utility functions for reducing code duplication
# -----------------------------------------------------------------------------
+fn_display_usage() {
+ fn_log_info "Usage : $(basename $0) <source> <[user@host:]destination> [exclude-pattern-file]"
+}
fn_parse_date() {
# Converts YYYY-MM-DD-HHMMSS to YYYY-MM-DD HH:MM:SS and then to Unix Epoch.
@@ -110,6 +113,11 @@ SSH_DEST_FOLDER=""
SSH_CMD=""
SSH_FOLDER_PREFIX=""
+#display usage information if required arguments are not passed
+if [[ "${#@}" -lt 2 ]]; then
+ fn_display_usage
+ exit 1
+fi
SRC_FOLDER="${1%/}"
DEST_FOLDER="${2%/}"
EXCLUSION_FILE="$3"