I'm trying to set up rsync to synchronize my main web server to the remote server by adding newly generated files to the latter

This is the command that i use

rsync -avh --update -e "ssh -i /path/to/thishost-rsync-key" remoteuser@remotehost:/foo/bar /foo/bar

It seems that the web server actually transfers all files despite the '-update' flag I have tried different flag combinations (e.g. omitting '-a' and using'-uv' instead) but none helped. What should i do to modify the command rsync to send only newly added files?

Best Answer


From man rsync .

--ignore-existing       skip updating files that exist on receiver

--update does something slightly different, which is probably why you are getting unexpected results (see man rsync ).

This forces rsync to skip any files which exist on the destination and have a modified time that is newer than the source file. (If an existing destination file has a modification time equal to the source file's, it will be updated if the sizes are different.)