rsync when working on both sides...

Christian Schneider christian.schneider at uni-kassel.de
Sun Oct 30 15:40:45 GMT 2005


Hi rsync devs and users,

I want to use rsync to synchronize home directories on two PCs. It works 
fine if I start rsync after working on a host each time I leave. But 
instead of operating modes "host1 -> host2" and "host2 -> host1" I would 
like to have a mode "host1 <-> host2" to allow synchronizing at any time
-> Scenario:
- on host1 files A,B have been created, C has been deleted
- on host2 file D has been modified, E deleted
Desired result after invoking rsync:
- host1 and host2 have files C,E removed and A,B,D updated
Is there an rsync switch supporting this?

As I have not found such a switch I'm using the script at the end of 
this mail - which seems to work fine (provided that the created file 
'syncedfiles.local' is available).
Any obvious problems?

Best regards,
Christian Schneider

-- skript following --

#!/bin/bash
NAME=username
DIR=/home
REMOTE=username at host::home

echo "*** delete files at remote side that were deleted locally (since 
last find) ***"
#ATTENTION: this deletes even modified files on the remote side!
rsync -rtzogpu --progress --exclude="syncedfiles.*" 
--include-from=syncedfiles.local --filter "- **" --delete 
--modify-window=1 --existing $DIR/$NAME $REMOTE

echo
echo "*** delete files at local side that were deleted remotely (since 
last find) ***"
#ATTENTION: this deletes even modified files on the local side!
rsync -rtzogpu --progress --exclude="syncedfiles.*" 
--include-from=syncedfiles.local --filter "- **" --delete 
--modify-window=1 --existing $REMOTE $DIR

echo
echo "*** copy new file to remote side ***"
rsync -rtzogpu --progress --exclude="syncedfiles.*" --filter "+ **" 
--modify-window=1 $DIR/$NAME $REMOTE

echo
echo "*** copy new file from remote side ***"
rsync -rtzogpu --progress --exclude="syncedfiles.*" --filter "+ **" 
--modify-window=1 $REMOTE $DIR

cd $DIR
find ./$NAME | sed -e 's/^.//' | grep -v syncedfiles > syncedfiles.local


More information about the rsync mailing list