Search code examples
linuxshellunixrsync

rsync to sync only current day files


I want to copy only current days files from remote server. is it possible through rsync?? I am trying below command but it is syncing all the files.

/usr/bin/rsync -avurzl #####@$$$$$$$$$ :/opt/test/logs/ /var/logs/


Solution

  • You can use find to find files that have changed in the past N days, and combine it with rsync like so:

    find . find -mtime +1 -print0 | xargs -J % -0 rsync -aP % user@host:some/dir/