jw schultz
2003-Jun-03 08:49 UTC
Rsync: --link-dest when target and compare_dir both have file
On Mon, Jun 02, 2003 at 03:32:04PM -0700, Michael Rubel wrote:> Hi J.W., > > Please pardon this intrusion on your private address; the rsync list seems > to be down (no messages since yesterday), so I'm forwarding this directly > to you. If you'd rather wait until the list restarts, that's fine too.I'm CCing the list.> > Best regards, > Mike > > ---------- Forwarded message ---------- > Date: Mon, 2 Jun 2003 09:56:50 -0700 (PDT) > From: Michael Rubel <mrubel@galcit.caltech.edu> > To: rsync@lists.samba.org > Subject: --link-dest when target and compare_dir both have file > > Hi J.W. et al, > > Kevin Everets was kind enough to inform me about some strange behavior in > his backup script, which seems to be the result of --link-dest behaving > unexpectedly in the case where target/ is already populated with older > versions of the same file. > > Here's the situation: > > We want to do: > $ rsync -a --link-dest=../backup.1 source/ backup.0/ > > There is a file present under all three directories. Suppose that it the > version in backup.1/ is identical to the version in source/, and that > backup.0/ contains an older version. > > In this case, I would expect: > 1. the version in backup.0 should be unlinked > 2. a new hard link should be created in backup.0/ to the copy in backup.1/ > > In fact, rsync (at least as of 2.5.6) seems to copy the full file:--link-dest is built on --compare-dest and behaves like --compare-dest as indicated in the manpage. Observe the description of --compare-dest (ALLCAPS added for emphasis): This option instructs rsync to use DIR on the des? tination machine as an additional directory to com? pare destination files against when doing transfers IF THE FILES ARE MISSING IN THE DESTINATION DIREC? TORY. In other words, the files in the --link-dest location will only be used if there is no existing file in the destination. The best way to use --link-dest is to have an empty destination. For a link-dest based rotating backup that reuses directory names the best bet is to do a "rm -r $dest; mkdir $dest" or to "rsync -a --link-dest=../backup.1 $source temp; mv temp backup.0" -- ________________________________________________________________ J.W. Schultz Pegasystems Technologies email address: jw@pegasys.ws Remember Cernan and Schmitt
Michael Rubel
2003-Jun-03 15:39 UTC
Rsync: --link-dest when target and compare_dir both have file
Everyone: apologies for hitting the list twice; when my first message did not go through I thought I'd used the wrong From: address. J.W.: Thanks very much, this clears it up nicely:> --link-dest is built on --compare-dest and behaves like > --compare-dest as indicated in the manpage. > > Observe the description of --compare-dest (ALLCAPS added for > emphasis): > This option instructs rsync to use DIR on the des? > tination machine as an additional directory to com? > pare destination files against when doing transfers > IF THE FILES ARE MISSING IN THE DESTINATION DIREC? > TORY. > > In other words, the files in the --link-dest location will > only be used if there is no existing file in the > destination. The best way to use --link-dest is to have an > empty destination. > > For a link-dest based rotating backup that reuses directory > names the best bet is to do a "rm -r $dest; mkdir $dest" or > to "rsync -a --link-dest=../backup.1 $source temp; mv temp > backup.0"I'll make a note on the snapshot page and respond to the person who forwarded it to me. Mike
Reasonably Related Threads
- rsync --link-dest option with the destination directory containing old files.
- --link-dest when target and compare_dir both have file
- [Fwd: Re: rsync windows -> unix still hanging :(]
- [Fwd: Re: rsync windows -> unix still hanging :(]
- possibly new rsync trick: rotating snapshots