I have the following scenario:

I have files in one directory where there is a process that is changing some files and updating the ctime on all files. I want to rsync all files to a target directory but preserve the ctime of those files that only got their ctime updated.

I have tried the following (~/source/test.txt is my source file and ~/target/test.txt is my target file).

chmod a+w source/test.txt (updates ctime but not mtime)
rsync -a -v -c --copy-dirlinks --delete --partial --inplace source/test.txt target

My expectation was that those files that have only their ctime updated in the source directory do not get rsync'd and apparently that is the case. But the corresponding file in the target directory still gets its ctime updated - which is currently causing trouble with my backup process.

Is there any way to have rsync not update the ctime for files that have not been modified?

  • The correct way is to prevent your process from modifying the ctime if it's not really changing the file. – Sven Oct 9 '14 at 12:54
  • @SvW Unfortunately this is out of my hands: It's so-called "enterprise software" which I have no way of influencing in any way – Benedikt Oct 9 '14 at 12:58

You could try if the --checksum option does what you want:

-c, --checksum

This changes the way rsync checks if the files have been changed and are in need of a transfer. Without this option, rsync uses a "quick check" that (by default) checks if each file's size and time of last modification match between the sender and receiver. This option changes this to compare a 128-bit checksum for each file that has a matching size. Generating the checksums means that both sides will expend a lot of disk I/O reading all the data in the files in the transfer (and this is prior to any reading that will be done to transfer changed files), so this can slow things down significantly.

When doing a short test, this worked, but not when using the shortcut -a option, maybe because it includes -t, which preserves mod times.

  • Agreed - use -c and -rlpgoD instead of -a and this should leave all the equal checksum files ctime unmodified. However, will update the ctime on files that are not skipped. Unfortunately, if there is ever a case of the source file being modified but maintaining the same checksum then this will be skipped. – geedoubleya Oct 9 '14 at 13:39

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.