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@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
On Sun, 2005-10-30 at 16:40 +0100, Christian Schneider wrote:> 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 > [...]I first learned to use rsync in the hope that it would provide a similar two-way synchronization solution, and when I failed to find a switch, I went so far as to submit a Request for Enhancement, but that really isn't what rsync is designed for. I rigged up a shell script called "msync" similar to yours but that is reluctant to delete things; this script and a corresponding "msync-rm" are attached in case you are interested. Try Unison instead. It is available here: http://www.cis.upenn.edu/~bcpierce/unison/ -- Matt McCutchen, ``hashproduct'' hashproduct@verizon.net -- http://mysite.verizon.net/hashproduct/ -------------- next part -------------- A non-text attachment was scrubbed... Name: msync Type: application/x-shellscript Size: 1897 bytes Desc: not available Url : http://lists.samba.org/archive/rsync/attachments/20051030/e29e0fdd/msync.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: msync-rm Type: application/x-shellscript Size: 138 bytes Desc: not available Url : http://lists.samba.org/archive/rsync/attachments/20051030/e29e0fdd/msync-rm.bin
On 10/30/05, Christian Schneider <christian.schneider@uni-kassel.de> wrote:> 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@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.localI would add "--temp-dir=/tmp" to each of the rsync commands so that you don't transfer partial files from another sync process. Otherwise, I'd take a look at unison, which does real bidirectional syncs. -- Aaron W Morris (decep) <aaronwmorris@gmail.com>