exclude open file in backup with rsync

Matt McCutchen hashproduct at verizon.net
Wed Mar 22 21:44:32 GMT 2006

On Wed, 2006-03-22 at 19:27 +0530, IMCC wrote:
>    I have to take a backup of files on a drive But 
>    I  have to exclude those file in a drive which are open. 
>    I want to know  whether rsync exclude open files
>    while taking backup ? .

Rsync sends all files without checking whether they are open.  If a file
is being read concurrently, rsync will send it correctly.  If a file is
being written concurrently, rsync will transfer each piece of the file
as it existed at the moment rsync read that piece.  That means you can
potentially get a combination of new and old data.  _If_ the concurrent
writing continues after the second during which rsync stats the source
file, the source file will be newer than the destination file and rsync
will fix the destination file when you next run it.

You might be able to get your operating system to enforce mandatory
locking on the files in question, in which case if the writer takes a
write lock, rsync's reading will be delayed until the writing finishes.
To simply exclude open files, you could run fuser on all the files and
translate the results into exclude rules, but files might open and close
after rsync starts.
Matt McCutchen
hashproduct at verizon.net

More information about the rsync mailing list