I have the following rsync set up, which is supposed to sync CDR files created during the past day.

rsync -av root@vpsrv:'$(find /home/cdrs/*.cdr -type f -ctime -1)' /home/cdrs

However, if no files are found, then this command will sync the entire /root directory for some reason. I've even tried to prevent this by adding include= filter:

rsync -av --include="*.cdr" root@vpsrv:'$(find /home/cdrs/*.cdr -type f -ctime -1)' /home/cdrs

Or even grepping for *.cdr:

rsync -av --include="*.cdr" root@vpsrv:'$(find /home/cdrs/*.cdr -type f -ctime -1 | grep *.cdr)' /home/cdrs

but no luck. Do you have any ideas?

link|improve this question

50% accept rate
What's wrong with syncing older *.cdr files? – Ignacio Vazquez-Abrams Nov 29 '10 at 10:28
We have an SQL loader on the other side, which moves CDRs to a different directory after loading them. If I keep syncing older files, the SQL loader will attempt to load them every time. Of course, if you have a better alternative, I'm open to suggestions. – Dario Nov 29 '10 at 10:52
feedback

1 Answer

up vote 1 down vote accepted
cd /home/cdrs && find /home/cdrs/*.cdr -type f -ctime -1 | rsync -av --files-from=- (source) (target)

The important bit is the '--files-from=-', which expects the list of files to be transferred from STDIN. It expects the filenames relative to the source-folder - that explains the 'cd /home/cdrs'...

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.