question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

rsync does not detect when local file changes content without changing size

See original GitHub issue

Hey all,

I work on a decent size team and we use the gsutil across a wide number of projects to support our devops and deploy tasks. If the -m flag is left off there will be a warning when using commands like gsutil rsync, this leads a reasonable developer to do the right thing and update any scripts which shell out to gsutil to use the -m flag.

A problem with this scenario, that has bitten us numerous times, is that the content matching causes edits like single line config changes to be treated as if there is no change at all. The gsutil tool will treat locally updated files as if they are the same as outdated content in the storage buckets. Sometimes we can catch this early but often it takes quite a bit of debugging and head scratching to arrive at the cause of unexpected behavior being the -m flag.

Sometimes in our code the flag will be removed, only to be added again later by a different, well meaning developer later.

I don’t have a specific solution to this but have been bitten by numerous times. I think, at the very least the warning/suggestion to use the flag should clearly mention this undesired side effect and what other flags should be added to get around issues if it is used.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
thobrlacommented, Mar 17, 2016

This behavior doesn’t have anything to do with the presence of the -m option. Instead, it is related to the -c option - see the “CHANGE DETECTION ALGORITHM” section of gsutil help rsync.

By default, gsutil does not perform a full checksum of local files, but checks only their sizes. If you expect that files will change contents without changing size, you’ll need to use the -c option to trigger checksumming that will detect these changes. The downside is that this generates a lot of local disk I/O, since every local file within the scope of the rsync must be read. This is why the option is turned off by default.

0reactions
Somebicommented, Nov 19, 2019

When copy project files, for example javascript files, this is very important to check checksum, because size won’t do the job. Simple example, just swap arguments in the function, this won’t change the size of file, but will change the logic of function and this won’t be copied with rsync, without -c flag. I have spent some time to understand this one (behaviour of rsync)…

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to rsync only new files - Unix & Linux Stack Exchange
I just found the -c option. It skips existing files based on a checksum, instead of modification time or size. – haheute. Mar...
Read more >
How to Use Rsync to Sync New or Changed/Modified Files in ...
In this article, we shall examine how rsync can help us only sync new or changed files or directory content while making backups...
Read more >
size-only not detect change only is size (but also time)?
--size-only Instead of the default behavior, rsync checks only that the file's size and any selected metadata to be transferred match on sender ......
Read more >
rsync NOT changed file - Stack Overflow
when I do "rsync src dest" I want to force to download some specific file even if it is the same( have the...
Read more >
How to print files that would have been changed using rsync?
Rsync has a dry-run option: -n, --dry-run show what would have been transferred. I am not sure if this is what you want....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found