]> git.treefish.org Git - backmeupscotty.git/blobdiff - backmeupscotty
Abort sync if source directory does not exist or is empty
[backmeupscotty.git] / backmeupscotty
index 0af4cd5927c371d515f45d36c9241945e6d2bbfd..e9bab430abb4c03726c44a4338255499d266a000 100644 (file)
@@ -27,6 +27,16 @@ function scottysync {
 
     echo BACKMEUPSCOTTY: Syncing $1 to $REMOTE_HOST:$REMOTE_BASE/$2 @$timestamp
 
+    if [ ! -d "$1" ]; then
+       echo BACKMEUPSCOTTY: Source dir $1 does not exist. Not syncing! >&2
+       return 1
+    fi
+
+    if [ $(ls -A "$1" | wc -l) -eq 0 ]; then
+       echo BACKMEUPSCOTTY: Source dir $1 is empty. Not syncing! >&2
+       return 1
+    fi
+
     dir_current=$REMOTE_BASE/$2/current
     dir_incomplete=$REMOTE_BASE/$2/incomplete
     dir_timestamped=$REMOTE_BASE/$2/$timestamp-$(date -d @$timestamp +%Y%m%d%H%M%S)