Sample Header Ad - 728x90

How rsync decides which files needs to be updated?

4 votes
1 answer
5962 views
Right now I have these commands: my_dir="$HOME/foo/bar"; rm -rf "$my_dir/WebstormProjects/"; rsync -r --exclude=".git" --exclude="node_modules" "$HOME/WebstormProjects/" "$my_dir/WebstormProjects/" instead of removing everything in "$my_dir/WebstormProjects/" and then copying over, I am looking to use rsync such that it will only overwrite files in "$my_dir/WebstormProjects/" if the files in "$HOME/WebstormProjects/" are newer. So something like this: my_dir="$HOME/foo/bar"; rsync -r --newer --exclude=".git" --exclude="node_modules" "$HOME/WebstormProjects/" "$my_dir/WebstormProjects/" **is it possible to copy files only if they are newer than the destination files?** I did some reading: https://www.tecmint.com/sync-new-changed-modified-files-rsync-linux/ it says: > By default, rsync only copies new or changed files from a source to > destination... I assume it does this by comparing relative file paths? Files with the same path/name are considered to be the same?
Asked by Alexander Mills (10734 rep)
Aug 13, 2018, 10:35 PM
Last activity: Feb 4, 2025, 11:53 AM