1

I want to transfer changed and new files only, using rsync on Ubuntu 14.04. I don't want to transfer everything, every time. I'm not worried about checking if the content of the files have actually changed. Similar posts exist, but I'm unsure because the documentation doesn't align with what is said in those posts.

The documentation in rsync says:

-u, --update

This forces rsync to skip any files for which the destination file already exists and has a date later than the source file.

http://ss64.com/bash/rsync_options.html

Edit: Found another (probably more official) documentation page. It says:

-u, --update skip files that are newer on the receiver

https://download.samba.org/pub/rsync/rsync.html

I find these poorly worded. Firstly, the first one says "date". I assume it actually means "timestamp". Secondly, and more importantly, it seems to imply that a file in both source and destination with the same timestamp will be re-transferred. The documentation clearly says that it will only skip a file when the destination file has a newer (i.e., later) timestamp (T_d) than the source file timestamp (T_s), implying that it will transfer when the destination file is older than or equal to the source file: Skipping transfer if T_d > T_s implies that it transfers when T_d <= T_s.

This is an important question to me, because if you want to transfer all new and changed files from a source folder to a destination folder with as little work (network/io/cpu/time) as possible the update flag might just re-transfer everything every time.

Or maybe I'm missing something, or misunderstanding something?

(This post was rejected from stackoverflow.com due to off-topic. Adding it, and the answer, here in case it might help people in the future.)

2

Found the following in the man expanding on the flag:

-u, --update

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.)

https://download.samba.org/pub/rsync/rsync.html

Thus the equal case checks the size of the files, and transfers only if they are different. I'm fine with this.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.