I would like to rsync folders from a specific date and forward. for example. I want to rsync my folders that were created from 3 days ago (and of course 2 days ago, one day ago etc.). I know I need to use find and rsync but I'm not sure how. any idea? Thanks! Dotan.

  • It is not the same "from a specific date forward" than "created from 3 days ago". Could match today, but tomorrow...
    – dstonek
    Dec 5 '16 at 18:28
rsync --progress --files-from=<(find /src_path -mtime -3 -type f -exec basename {} \;) /src_path/ /dst_path
  • Well placing in cron fails with error "rsync: failed to open files-from file <(find /......;): No such file or directory rsync error: syntax or usage error (code 1) at main.c(1084) Jul 1 '16 at 14:14
  • @user1595858 did you just pasted the command as is? :-V. There's a typo in the /src_path-mtime, missing space.
    – m3nda
    Apr 21 '18 at 0:25
  • whoops, fixed the typo
    – fredrik
    Apr 22 '18 at 13:01
  • Here is what worked for me: # 1) Go to the directory you want to sync FROM # 2) Define the number of days with (-mtime +day)[newer than] or (-mtime -day)[ older than] rsync -av --progress --files-from=<(find . -type f -mtime -1 ) ./ /my_backup/
    – gryzli
    Aug 12 '20 at 11:00
  • 1
    @user1595858, cron might run the commands with /bin/sh, which is only guaranteed to be a POSIX shell. The <(command) syntax is a bash extension Apr 22 '21 at 11:04

You would want to do a find then sync

find /path -file -mtime +3 -exec rsync {} destination \;
  • 1
    I think this is what I was looking for: find /path -d -mtime -3
    – edotan
    Sep 13 '13 at 20:46

Modifying the answer from Thomas which syncs based on the modifiction date of a file to a script, to be more human readeable and sync nested folders as well.



touch $TARGET/last_sync

rsync \
    -ahrv \
    --update \
    --files-from=<(ssh $HOST "find $SOURCE -type f -newer $SOURCE/last_sync -exec realpath --relative-to=$SOURCE '{}' \;") \

rsync -ahv $TARGET/last_sync $HOST:$SOURCE

For init one should probably create a last_sync file remotely, to which the following command comes in handy

touch -d "2 hours ago" last_sync

which creates a file called last_sync with a creation date of 2 hours ago.


Assuming you want to sync some folder from a server to a local folder but you always want to only sync the files that have been created since the last sync. Then the following command might be useful. Putting this in, e.g., your .bashrc defines an alias that syncs all the newly created files. The files can be locally deleted and will not be synced again when calling the sync command again. Only files that have been created after the last sync on the server will be copied to the local folder.

alias sync-since-last="touch $TARGET/last_sync && rsync -ahv --update --files-from=<(ssh user@SERVER.IP 'find $SOURCE/source/ -type f -newer $SOURCE/last_sync -exec basename {} \;') user@SERVER.IP:$SOURCE/source/ $TARGET && rsync -ahv $TARGET/last_sync user@SERVER.IP:$SOURCE"
  • Uh... you are using ssh to get to the server, but are touching a file locally that the server is supposed to access?
    – Michael
    Dec 8 '19 at 4:50
  • 1
    In the last step, that file is moved to the server. This way, the start date and time for the next sync is set to right before the sync starts. And it is only set if the sync finished correctly.
    – Thomas
    Dec 8 '19 at 7:02

For particular date you can use below command from current directory:

for file in $(ls -ltr *.gz | grep 'Apr 17' | awk {'print $9'} | xargs ls)
  do rsync -avzh --progress -e ssh $file  user@*******:/tmp

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.