jim at meyering.net
Tue Jan 29 19:47:18 EST 2002
tim.conway at philips.com wrote:
> Here's an example.
> dest = directory tree full of files all interdependent. a change in one
> without the corresponding change in another makes the whole tree invalid.
> If you just rsync the directory changes over, the tree is invalid from the
> first change is started until the last one is done.
> To avoid this, you rsync to another directory in the same filesystem,
> using --compare-dest to point to the actual directory.
> Once the new copy is finished, you rename the original to a temporary
> name, rename the new copy to the originals name (these two operations are
> nearly instantaneous), then recursively delete the original directory.
> This way, there is no time at all where the directory is invalid, and only
> maybe a millisecond where it doesn't exist.
You can eliminate that small missing-directory window if you don't
mind making all `regular' uses go through a symlink. I do that
with a CVS repository mirror.
Say the official name is /cvsroot, but /cvsroot is just a symlink to
cvsroot-a. You could use rsync to put a newer snapshot of the master
alongside /cvsroot-a, using that hierarchy as the basis (via --compare-dest)
for creating /cvsroot-b. Once the rsync completes, you can change the
/cvsroot symlink to point to the newer hierarchy: cvsroot-b.
Of course, with CVS, you have to be careful with locks, so you'd
have to obtain write locks for all directories in /cvsroot (aka cvsroot-a)
before toggling the symlink. Once the symlink is switched, you can
Hmm... currently, the above requires enough space for two copies of
the repository. Ideally, in some cases, rsync could get away with
using little more than the space for the original repository.
Assuming source and destination are on the same partition, and
assuming there are many files that have not been modified at all
for a given snapshot (e.g., no tags), it'd be nice if rsync had an
option to go along with --compare-dest that would make it create
hard links for files that are identical, rather than taking the
time/space to copy them.
More information about the rsync