I have this bash script running my backup to an external hard drive... only if that drive is mounted (OS X):
DIR=/Volumes/External;
if [ -e $DIR ];
then rsync -av ~/dir_to_backup $DIR;
else echo "$DIR does not exist";
fi
This works, but I sense I am misreading the rsync man page. Is there a builtin rsync option to abort the run if the top level destination directory does not exist? Without testing for the existence of /Volumes/External, a directory will be created by that name if it isn't already mounted.