Syncing file with reference to another one

Ryan Malayter malayter at gmail.com
Mon Dec 15 23:41:53 GMT 2008


On Mon, Dec 15, 2008 at 5:28 PM, Hai Zaar <haizaar at codefidence.com> wrote:
> I have the following situation: file2 on remote host and file1 on
> localhost. file1 and file2 are mostly the same. Simply running
>  rsync remotehost:file2 file2
> will actually transfer the entire file. But I would like to use the
> factt that I have local file1 that is mostly similar to file2. I.e.
> how can I make rsync to use file1 as a reference while transferring
> file2? (cp file1 file2 locally and then using --inplace switch to
> rsync sound like and idea, but look awkward for me. Anything better?)

The --fuzzy option will do what you want, provided the files are both
in the same directory and have similar names (such as file1 and file2
or backup20081210.tgz and backup20081217.tgz). The details of the
filename matching algorithm are in the source code, but my experience
is that it seems to do the right thing most of time. The "best" file
might not be selected by --fuzzy if there is a boundary condition in
your filenaming convention. For example, rollover from file8 to file9
to file1 will likely cause the use of file2 by the -fuzzy option, even
though file9 might be "more similar" in actual content.

-- 
RPM


More information about the rsync mailing list