From 8d7e0fed296a508b7c2ff2ec93fdba655186fbf7 Mon Sep 17 00:00:00 2001 From: Alexander Schmidt Date: Tue, 10 Jun 2014 20:47:37 +0200 Subject: [PATCH] Abort sync if source directory does not exist or is empty --- backmeupscotty | 10 ++++++++++ 1 file changed, 10 insertions(+) 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) -- 2.39.5