I have a server from which I want to copy files and directories to a local destination. The local destination does not have any of the files or directories on it. Instead of copying all files on the server to the local machine, I would like to only update any new files that are put on the server to the local destination.

Thus, I'm assuming that a time stamp of some sort could be used to filter the preexisting files for a rsync transfer. How would I go about doing this?


One of the ways to do that would be to use rsync with find.

rsync <options> <source> <destination>
rsync -azv username@server:'$(find source_dir/ -mmin -120 -type f)' destination_dir/

This command will compress and archive files found under source_dir on server that were modified in the last 2 hours and rsync them to destination_dir (local destination). You may have to modify this command to suit your needs.

  • This breaks if files have a space in their name. – slhck Jul 21 '13 at 10:34
  • 1
    It would be better to use something like --files-from parameter, this command smells like it's just waiting to blow up. – Bobby Jul 21 '13 at 10:53
  • So are there any other methods to go about doing this? – arete Jul 23 '13 at 7:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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