0

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?

Ariod
  • 179
  • 2
  • 5
  • 13
  • 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. – Ariod Nov 29 '10 at 10:52

1 Answers1

1
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'...

heiko
  • 1,733
  • 1
  • 12
  • 6