LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 12-08-2006, 09:06 AM   #1
bkeeper
LQ Newbie
 
Registered: Dec 2005
Location: Muenchen, Germany
Posts: 25

Rep: Reputation: 16
Cool 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
 
Old 12-08-2006, 11:36 AM   #2
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 197Reputation: 197
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.
 
Old 12-11-2006, 04:16 AM   #3
bkeeper
LQ Newbie
 
Registered: Dec 2005
Location: Muenchen, Germany
Posts: 25

Original Poster
Rep: Reputation: 16
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
 
  


Reply

Tags
rsync


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
rsync: error while copying Fusi Linux - Software 5 06-09-2013 11:00 PM
LXer: Visually impaired prevent Massachusetts move to open source LXer Syndicated Linux News 0 08-21-2006 03:54 PM
LXer: If open source on its own doesn't prevent vendor lock-in, what's ... LXer Syndicated Linux News 0 04-29-2006 10:33 AM
how to prevent listing hidden files from been shown? greythorne Suse/Novell 5 03-16-2005 09:01 AM
Copying from Slackware 10 to Debian Sarge using rsync apolinsky Slackware 5 10-07-2004 09:17 AM


All times are GMT -5. The time now is 10:59 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration