On 10/30/05, 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
> -> 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=3Dusername
> DIR=3D/home
> REMOTE=3Dusername@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=3D"syncedfiles.*"
> --include-from=3Dsyncedfiles.local --filter "- **" --delete
> --modify-window=3D1 --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=3D"syncedfiles.*"
> --include-from=3Dsyncedfiles.local --filter "- **" --delete
> --modify-window=3D1 --existing $REMOTE $DIR
>
> echo
> echo "*** copy new file to remote side ***"
> rsync -rtzogpu --progress --exclude=3D"syncedfiles.*" --filter "+ **"
> --modify-window=3D1 $DIR/$NAME $REMOTE
>
> echo
> echo "*** copy new file from remote side ***"
> rsync -rtzogpu --progress --exclude=3D"syncedfiles.*" --filter "+ **"
> --modify-window=3D1 $REMOTE $DIR
>
> cd $DIR
> find ./$NAME | sed -e 's/^.//' | grep -v syncedfiles > syncedfiles.local


I would add "--temp-dir=3D/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)
--
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html