[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: rsync -



Andras Simon wrote:
On 5/14/09, Bob Goodwin <bobgoodwin wildblue net> wrote:
I have two f-10 desk top computers, boxes 6 and 9. I use them
interchangeably and keep notes [notecase] in both. I would like to
update each from the other without losing anything in the process.

The name "rsync" seems to imply that it will make them identical. Does
that mean if the source has fewer files than the target the target will
have some deleted? Is there a command string to ensure I wont lose
anything?

If you change the files "in parallel" on both computers, then I'm
afraid you'll have to manually merge them. The only tool I know about
which helps with this is Emacs' emerge (which, for all my love for
Emacs, I find nearly unusable), but there must be others.

Yes, parallel changes won't easily be handled by anything. I guess you
could try some sort of version control, but even that's difficult to use
if the files are binary. But if the issue is just that you may have made
some changes on both machines, but to different files, then rsync is
perfect.

I use the attached bash script to rsync my laptops, work machine, and
such with my file server, which I otherwise mount via NFS for my home
machines. I'm sure it or some version of it would work simply to keep
sync two machines in sync.

Richard


#!/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...";

*~
*.bak
*.backup
photos/
.Trash-*/
*.xac
*.log
cache/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]