Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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
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'...

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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