lock files

David Bolen db3l at fitlinxx.com
Wed Sep 12 06:39:55 EST 2001


Dietrich Baluyot [dietrich.baluyot at lavalife.com] writes:

> Does rsync lock the source files while its copying?

No (there's really no guaranteed portable way to do it anyway).

But rsync does perform a final checksum on transferred files and if
they differ, it will re-execute the transfer (with an adjustment to
the checksum algorithm).  This is intended to catch the rare case
where the checksums can be fooled into thinking a portion of the file
is unchanged, but it can also catch changes under the covers while
rsync is moving the file.

However, it's not an absolute guarantee since rsync uses stored
directory information (such as overall file size) I believe, so it's
possible for a growing file to not include everything added during the
execution of rsync.

If you need absolute guarantees on a changing file, you need to apply
your own locking around rsync.  For example, in copying back database
backups I use a script that creates a lock file before running rsync,
and that lock file is also checked by the backup script.

-- David

/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/




More information about the rsync mailing list