Compare checksum in addition to (not instead of) modtime?

I am wondering if it is possible to compare each file's hash in addition to (not instead of) its modtime, during a sync or copy operation.

Ideally, I am looking for one flag configuration that behaves in the following way:

  • When all three of size, modtime, and hash are available, compare all three, and if ANY of the three are not identical, replace the destination file with the source file.

  • When only 2 of the 3 are available (such as when syncing local to crypt backend which does not support hash), ignore the one that’s not available but still check the other two.

--checksum does not accomplish this because:

  1. When hash is available, it will not check modtime
  2. When hash is not available, it will fall back to --size-only (and still not check modtime)

#2 is the greater concern for me, because instead of simply ignoring the --checksum flag and using the default (modtime and size), it actually substitutes a different flag (--size-only) which is less accurate than the default.

--refresh-times also does not accomplish this, because it has no effect when used with --checksum, and on a crypt backend it would only update the timestamp, not the file contents.

Ideally I'm looking for one flag configuration that is agnostic to whether or not the source and dest have hashes in common, because I am scripting some sync tasks that reuse the same commands with different source:path and dest:path variables, which will sometimes have a common hash and sometimes not. I could add some logic to check both remotes each time for a common hash and add -c only if it finds one, but this would be a little more complicated and still wouldn't address issue #1 above.

Omitting --checksum across the board also does not do what I'm looking for, because then hashes would not be checked for files with matching size and modtime (even when hash is available.)

The command I normally use is:
rclone sync source:path dest:path --create-empty-src-dirs -MPc --drive-skip-gdocs -v

Is this possible? Grateful for any advice!

Not with the current set of flags.

However what you can do is do a modtime sync, then do an rclone check which will go through and check all the checksums.

I had a vague idea to make the sync key configurable. At the moment it is size,modtime by default, size, checksum if --checksum is in use and size if --size-only is in use. What you want is size,modtime, checksum I think.

Ok. Thank you for confirming!

And I think the configurable sync key idea sounds great!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.