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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Peter SchultzSenior 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David FavorLinux/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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.