From owner-freebsd-questions@FreeBSD.ORG Thu Jan 10 19:09:27 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 40619EBA for ; Thu, 10 Jan 2013 19:09:27 +0000 (UTC) (envelope-from cswiger@mac.com) Received: from nk11p00mm-asmtp005.mac.com (nk11p00mm-asmtp005.mac.com [17.158.161.4]) by mx1.freebsd.org (Postfix) with ESMTP id 133E1170 for ; Thu, 10 Jan 2013 19:09:26 +0000 (UTC) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII Received: from cswiger1.apple.com ([17.209.4.71]) by nk11p00mm-asmtp005.mac.com (Oracle Communications Messaging Server 7u4-26.01(7.0.4.26.0) 64bit (built Jul 13 2012)) with ESMTPSA id <0MGF008OKBVJYH00@nk11p00mm-asmtp005.mac.com> for freebsd-questions@freebsd.org; Thu, 10 Jan 2013 19:09:19 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.9.8327,1.0.431,0.0.0000 definitions=2013-01-10_09:2013-01-10,2013-01-10,1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 ipscore=0 suspectscore=1 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=6.0.2-1203120001 definitions=main-1301100157 Subject: Re: Syncing Two Dirs With Rsync From: Chuck Swiger In-reply-to: <50EF0F1F.8080904@tundraware.com> Date: Thu, 10 Jan 2013 11:09:19 -0800 Message-id: <67BEF7CB-1FC4-43EB-AFF8-8ECD3A68B214@mac.com> References: <50EF0F1F.8080904@tundraware.com> To: tundra@tundraware.com X-Mailer: Apple Mail (2.1085) Cc: FreeBSD Mailing List X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Jan 2013 19:09:27 -0000 On Jan 10, 2013, at 10:57 AM, Tim Daneliuk wrote: > I have used rsync for many years to make sure a destination > machine:directory is kept up-to-date with some source master > directory. > > I now need to find a way to keep two different machine:dirs > in sync with each other. But for any given file, I don't know > which of these is newer so I don't know "which way" to sync. > > For example given: > > machineA::/dir/foo machineB:/dir/foo > machineA::/dir/bar machineB:/dir/bar > > Say the machineA has the newest foo, but machineB has the > newest bar. At the end of syncing, I want both machines > to have the latest copies of everything. > > I'm guessing there's a way to do this with rsync but I'm kind > of stumped. rsync's --update flag will not overwrite a file at the destination if it was modified more recently then the source location. So you can run rsync twice to sync from A to B and then from B to A. Make very sure both boxes are keeping correct time and/or are mutually sync'ed via NTP or similar. However, if you make different changes to the same file on A and on B, you will lose one of them. (That is what version control systems like SVN and git would resolve. So if you do plan to do 2-way or N-way changes and sync'ing on a regular basis, version control is much less likely to lose changes or otherwise screw up.) Regards, -- -Chuck