I would like to transfer a directory of files to a remote destination. Easy.
However, at any given time, one or many of these files may be in-use and being updated by users.
This doesn't bother rsync - it will happily transfer the files ... but the resulting destination directory may have half-written or half-created files in it.
I thought of perhaps running 'lsof' or checking /proc filesystem to determine whether files were in use and running rsync if they are not, but that's just a race - maybe someone writes or opens right as I do the rsync.
Or, I could check 'lsof', then lock the directory with chmod and then run the rsync ... again, possible race condition and if someone does try to access, they will get errors / denied.
How might this be done ?