Rsync all files except those that were more recently changed at the destination

I have rsync some files to a remote server.  Some of those files have been updated on the remote server and others of those files have been updated on the original server.  

I want to update the remote server so that it includes any changes to updated files on the original server but I don't want to overwrite anything on the remote server that has more recently been changed on the remote server than the original server.

Which rsync option should I use for this?
XetroximynAsked:
Who is Participating?
 
Peter SchultzConnect With a Mentor Senior Network AdministratorCommented:
Hi,
use the "--update" option.

"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.)"
1
 
David FavorConnect With a Mentor Linux/LXD/WordPress/Hosting SavantCommented:
I for some reason your destination file timestamp has changed + the contents are the same use these together...

--update --checksum

Open in new window


Keep in mind, using --checksum on large numbers of files or just large files, can be extremely CPU intense. Use --checksum with caution.
0
 
XetroximynAuthor Commented:
Thanks!  So to confirm originally I used -av . I reviewed everything that -a does, and it looks like I want that stuff... So would I now use the following?  (Basically trying to make sure --update will still work as expected with -a)

rsync -av --update src dst

Open in new window

0
 
Peter SchultzSenior Network AdministratorCommented:
confirmed.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.