--=-oNYPwz9uuYcS5CfbvCdS
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

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/

--=-oNYPwz9uuYcS5CfbvCdS
Content-Disposition: attachment; filename=msync
Content-Type: application/x-shellscript; name=msync
Content-Transfer-Encoding: 7bit

#!/bin/bash
# msync, Matt's synchronization script that uses rsync
# Set the following: dir1 dir2 mode extraoptions

cmd="cp2 -uv --progress $extraoptions"

cat <<"END"
--------------------------------------------------------------------------------
Matt's synchronization script, 10/24/2005 version

A single command synchronizes both ways. As for deletion: Zero-length files are
considered deletion-marked and get deleted during synchronization. This way,
deletion-marking is a kind of modification and competes with other modifications
for most-recent status. To make a file zero-length, run `msync-rm' (same as
`truncate 0') on it. Folders containing no files are also deleted during
synchronization, and this applies recursively, so a folder must contain,
directly or indirectly, at least one regular file of positive length to be safe.

Pass 1: Bring any updates from the remote directory to the local directory.
(Now the local directory has the newest version of everything.)
Pass 2: Delete empty files and folders in the local directory.
(Now the local directory has the file structure exactly how we want it.)
Pass 3: Make the remote directory an exact copy of the local directory.
(Now the two directories both have the correct file structure.)
--------------------------------------------------------------------------------
END

echo
echo "Operation: $syncname"
echo
echo "This will synchronize \`$dir1' and \`$dir2'."
echo "Proceed (yes/no)? Make sure you have access to both directories."
read choice

if [ "$choice" = "yes" ] ; then
echo "$0: Pass 1: Updating \`$dir1' <== \`$dir2'..."
if $cmd "$dir2" "$dir1" ; then
echo "$0: Pass 2: Deleting empty files and directories in \`$dir1'..."
find "$dir1" -depth -empty -execdir rm -r {} + # a little tuning
echo "$0: Pass 3: Updating \`$dir1' ==> \`$dir2'..."
$cmd --delete "$dir1" "$dir2"
fi
fi

--=-oNYPwz9uuYcS5CfbvCdS
Content-Disposition: attachment; filename=msync-rm
Content-Type: application/x-shellscript; name=msync-rm
Content-Transfer-Encoding: 7bit

#!/bin/bash
# msync deletion-marker, 11/15/2004
while [ "$1" != "" ] ; do
# Now that Matt wrote `truncate':
truncate "$1" 0
shift
done

--=-oNYPwz9uuYcS5CfbvCdS
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

--
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html
--=-oNYPwz9uuYcS5CfbvCdS--