Bash – Rsync Grabing Only New Files


I have a set of files in storage, and I would like to get only the new files and put it in another directory. Is there a way to do this?

For example:

The "old files" are contained in:

I would like the new files coming in from rsync to be put in folder/ [and my script would put it in oldfiles, after the file has been processed]

Is there anyway to do this with rsync?

Best Answer

  1. Use rsync --ignore-existing --dry-run --verbose SOURCE PROCESSED > OUTPUTFILE
  2. Process OUTPUTFILE to make sure it only contains file names
  3. Use rsync --files-from=OUTPUTFILE SOURCE PROCESSING
  4. Process each file in PROCESSING and move it to PROCESSED

Of course, you will want to add your usual options to the first rsync comand, e.g. --archive or --recursive.

Related Question