From: Alexander Schmidt Date: Tue, 10 Jun 2014 18:47:37 +0000 (+0200) Subject: Abort sync if source directory does not exist or is empty X-Git-Url: https://git.treefish.org/~alex/backmeupscotty.git/commitdiff_plain/8d7e0fed296a508b7c2ff2ec93fdba655186fbf7 Abort sync if source directory does not exist or is empty --- diff --git a/backmeupscotty b/backmeupscotty index 0af4cd5..e9bab43 100644 --- a/backmeupscotty +++ b/backmeupscotty @@ -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)