]> arthur.barton.de Git - backup-script.git/commitdiff
Make sure "system target directory" exists and is valid
authorAlexander Barton <alex@barton.de>
Thu, 26 Sep 2013 12:33:55 +0000 (14:33 +0200)
committerAlexander Barton <alex@barton.de>
Thu, 26 Sep 2013 12:33:55 +0000 (14:33 +0200)
bin/backup-script

index 45846b786ab7ad870a6f25f7ecc6d51a167927e6..5d3cb2da6f3ab4e488b7fa731dc1d2be5dda1f88 100755 (executable)
@@ -178,9 +178,14 @@ for f in $sys; do
                echo; continue
        fi
 
-       destdir="$target"
-       target="$target/$system"
-       [ "$DRYRUN" -gt 1 ] || mkdir -p "$target"
+       sys_target="$target/$system"
+       if [ "$DRYRUN" -eq 0 ]; then
+               mkdir -p "$sys_target" >/dev/null 2>&1
+               if [ $? -ne 0 ]; then
+                       echo "Can't create \"$sys_target\"!? \"$system\" skipped!"
+                       echo continue
+               fi
+       fi
 
        if [ "$local" -eq 0 -a "$ping" -ne 0 ]; then
                # Check if system is alive
@@ -207,17 +212,17 @@ for f in $sys; do
        [ -n "$rsync_args_add" ] && cmd="$cmd $rsync_args_add"
 
        [ "$local" -eq 0 ] \
-               && cmd="$cmd ${user}@${system}:/ $target" \
-               || cmd="$cmd / $target"
+               && cmd="$cmd ${user}@${system}:/ $sys_target/" \
+               || cmd="$cmd / $sys_target/"
 
        echo "Calling: $cmd"
        echo -n "Start date: "; date
        count_started=$count_started+1
-       rm -f "$target/.stamp"
+       rm -f "$sys_target/.stamp"
        
-       if [ "$DRYRUN" -lt 1 ]; then
+       if [ "$DRYRUN" -eq 0 ]; then
                $SHELL -c "$cmd"; ret=$?
-               echo "code=$ret" >"$target/.stamp"
+               echo "code=$ret" >"$sys_target/.stamp"
        else
                echo " *** Trial run, not executing synchronization command!"
                ret=0
@@ -239,7 +244,7 @@ for f in $sys; do
        fi
        echo -n "End date: "; date
 
-       destinations="$destinations $destdir"
+       destinations="$destinations $target"
        echo
 done