How to rsync files / folders from a specific date forward?

Solution 1:

rsync --progress --files-from=<(find /src_path -mtime -3 -type f -exec basename {} \;) /src_path/ /dst_path

Solution 2:

You would want to do a find then sync

find /path -file -mtime +3 -exec rsync {} destination \;

Solution 3:

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 [email protected] 'find $SOURCE/source/ -type f -newer $SOURCE/last_sync -exec basename {} \;') [email protected]:$SOURCE/source/ $TARGET && rsync -ahv $TARGET/last_sync [email protected]:$SOURCE"

Solution 4:

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.