#!/bin/bash
LOCAL_TO_REMOTE=0;
REMOTE_TO_LOCAL=0;
DELETE="";
LOCAL="/home/rgheck";
REMOTE="example.com:/home/rgheck";
EXCLUDE="/home/rgheck/bin/syncem.exclude";

select way in \
	"Local to Remote" \
	"Local to Remote, Delete Remote" \
	"Remote to Local" \
	"Remote to Local, Delete Local" \
	; do
	if [ "$way" = "Local to Remote" ]; then
		LOCAL_TO_REMOTE=1;
		break;
	elif [ "$way" = "Local to Remote, Delete Remote" ]; then
		LOCAL_TO_REMOTE=1;
		DELETE=" --delete ";
		break;
	elif [ "$way" = "Remote to Local" ]; then
		REMOTE_TO_LOCAL=1;
		break;
	elif [ "$way" = "Remote to Local, Delete Local" ]; then
		REMOTE_TO_LOCAL=1;
		DELETE=" --delete ";
		break;
	else
		exit;
	fi;
done

#To get things deleted FROM LOCAL, add "--delete"
#Should make that somehow an option....
#There to here...
if [ "$REMOTE_TO_LOCAL" = "1" ]; then
	rsync --dry-run -avuzb --backup-dir="$LOCAL/syncem.backup" --rsh="ssh" --exclude-from="$EXCLUDE" $DELETE "$REMOTE/files" $LOCAL
	echo "Continue?";
	select speed in Yes No; do
		if [ "$speed" = "Yes" ]; then
			echo "Running rsync for real...";
			rsync -avuzb --backup-dir="$LOCAL/syncem.backup" --rsh="ssh" --exclude-from="$EXCLUDE" $DELETE "$REMOTE/files" $LOCAL
			break;
		else
			break;
		fi
	done
fi

#Here to there...
if [ "$LOCAL_TO_REMOTE" = "1" ]; then
	rsync --dry-run -avuzb --backup-dir="$LOCAL/syncem.backup" --rsh="ssh" --exclude-from="$EXCLUDE" $DELETE "$LOCAL/files" $REMOTE
	echo "Continue?";
	select speed in Yes No; do
		if [ "$speed" = "Yes" ]; then
			echo "Running rsync for real...";
			rsync -avuzb --backup-dir="$LOCAL/syncem.backup" --rsh="ssh" --exclude-from="$EXCLUDE" $DELETE "$LOCAL/files" $REMOTE
			break;
		else
			break;
		fi
	done
fi
echo "All done...";

