Score:0

What is the difference between -i and -u options in gsutil rsync command?

mq flag
AKd

The gsutil rsync documentation describes two options which sound identical:

Option Description
-i 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.)
-u When a file/object is present in both the source and destination, if mtime is available for both, do not perform the copy if the destination mtime is newer.

Although they use different terms, mtime and modification time, still it seems to be the same. At least I have not found any info on the difference. Both options effectively state that the file will not be copied (skipped) if the destination file is newer.

However, there must be some difference. I can't assume that the product team kept two identical options by mistake.

What is the difference in effect of these two options?

The only possible difference may be in the case of equal modification times of the source and destination, as described in the parentheses. In this case, the documentation might be improved to explicitly link the two options and point out the only difference. At least the same terms should be used to avoid confusion.

I've asked a similar question on StackOverflow earlier, but it is not specific enough (leaning to the difference between terms “mtime” and “modification time”), hence the answer is not complete. Now I'm asking here because the question is not about programming, and the question is specific now.

John Hanley avatar
cn flag
Since the source code to `gsutil` is published, look in the source code for the answer since your goal is a better answer. Once you complete that review, post an answer.
AKd avatar
mq flag
AKd
Oh, I didn't know it is open source, thanks for hinting. If no one who knows the difference for sure answers, I will, of course, resort to looking in the source code.
Vaidehi Jamankar avatar
vn flag
`-u `option will check if a file/object is present at both the source and destination and if the `mtime` is available for both and if yes, then it does not perform a copy if the destination has newer(latest) `mtime`. `-i` option will force skip any file which are already present in the destination and have newer(latest) modification time.Also if modification time of destination file is equal to source file then it will check sizes and update if size is mismatched. I have just tried to put a little more explanation above,also as mentioned by John,it is published and the source is available.
AKd avatar
mq flag
AKd
Thanks. I've already looked at the source code, and found two PRs which added `-u` and `-i` options. And it seems to me that the description of the `-i` option is incorrect, as it just makes `rsync` to skip existing files regardless of the modification time. See [my comment on GitHub](https://github.com/GoogleCloudPlatform/gsutil/pull/1183#pullrequestreview-1224254773). The repo contributor tends to agree.
Vaidehi Jamankar avatar
vn flag
You can also raise a [Public Issue tracker](https://cloud.google.com/support/docs/issue-trackers) here with the details ,so the concerned team and take this further.
AKd avatar
mq flag
AKd
They are redesigning `rsync` soon, so perhaps the docs will also be rewritten.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.