Syncing file with reference to another one

Matt McCutchen matt at mattmccutchen.net
Tue Dec 16 23:00:58 GMT 2008


On Tue, 2008-12-16 at 01:28 +0200, Hai Zaar 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?)

Since you know the specific pair of files that are similar, I would just
use the cp approach.  There's no reason to use --inplace; if you are
trying to reduce disk I/O, a better way to do that is to hard-link file1
to file2 locally instead of copying.

If you don't like ever having incorrect data at the destination, you
could put the copy or hard link in another directory and use
--copy-dest.  In fact, I maintain a hard-linked series of backups of my
computer using rsnapshot, and I do something similar when I move a large
directory on the source: I pass a --link-dest directory containing a
symlink from the new path to the old path in the previous backup so that
rsync can find the moved but unchanged files.

-- 
Matt



More information about the rsync mailing list