]> git.treefish.org Git - backmeupscotty.git/commitdiff
Abort sync if source directory does not exist or is empty
authorAlexander Schmidt <alex@treefish.org>
Tue, 10 Jun 2014 18:47:37 +0000 (20:47 +0200)
committerAlexander Schmidt <alex@treefish.org>
Tue, 10 Jun 2014 18:47:37 +0000 (20:47 +0200)
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)