summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBhuvanesh Kumar <bhuvibhuvanesh@gmail.com>2014-01-29 00:18:38 +0530
committerBhuvanesh Kumar <bhuvibhuvanesh@gmail.com>2014-01-29 00:18:38 +0530
commit18258ad2a9eaf8b958978b8ec8a39b6b99032388 (patch)
tree43a54e5ad7f84346ce0dc96be9ef6d7fd6ee566b
parent45a90310e3b1f3b8cc45371cb8eca775ca4e7747 (diff)
display usage info if required args not passed
-rwxr-xr-xrsync_tmbackup.sh8
1 files changed, 8 insertions, 0 deletions
diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh
index e5192bd..2e83f5a 100755
--- a/rsync_tmbackup.sh
+++ b/rsync_tmbackup.sh
@@ -24,6 +24,9 @@ trap 'fn_terminate_script' SIGINT
# -----------------------------------------------------------------------------
# Small utility functions for reducing code duplication
# -----------------------------------------------------------------------------
+fn_display_usage() {
+ fn_log_info "Usage : $(basename $0) <source> <destination> [exclude-pattern file]"
+}
fn_parse_date() {
# Converts YYYY-MM-DD-HHMMSS to YYYY-MM-DD HH:MM:SS and then to Unix Epoch.
@@ -53,6 +56,11 @@ fn_expire_backup() {
# -----------------------------------------------------------------------------
# Source and destination information
# -----------------------------------------------------------------------------
+#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%/}"