prevent rsync from copying open files?
Hi there,
how can I find out whether a file is still being written? How can I tell rsync not to copy files which are still being written? Thanks to some great tutorials around I managed to set up a rsync cron job, backuping files from a very ;) remote machine to my computer. :) Now, on the remote machine there's a program running which writes data out in files and also, once in a while, creates a new file, closing the old one. I would like to copy only closed files, i.e. files that are not being written into any more. Otherwise I'd copy lots of data many times: As long as the file is still written, and a last time only once the file is closed. That's not what I want since the connection is very slow. Any ideas? Thank you already in advance! Cheers, bkeeper :) |
rsync is intelligent though. If you copy files once, it should only copy the incremental changes. Check the man page for many options rsync has. Although I don't recall an option to only copy files that are not opened by any process, you could either copy files with a particular timestamp or older or possibly write a script that uses lsof to search for open files and not include such files in the current rsync copy.
|
Hi Trickykid,
yes, you're right, how nice! :) I just tried it out and it works, only copying incremental changes, perfect! Thanks for the help! Cheers, bkeeper :) |
All times are GMT -5. The time now is 05:28 AM. |