Add support of `--crtimes, -N` for `rsync`
Currently rsync works fine in Windows with Git-Bash (How to install)
But it does not support --crtimes,-N — "preserve create times" flag.
I use Robocopy.exe now, it keeps file creating date by default, but it does not have any flag to verify checksum (-c, --checksum) while rsync does not support keeping of file creating time since this feature is not implemented:
rsync: This rsync does not support --crtimes (-N)
rsync error: syntax or usage error (code 1) at main.c(1746) [client=3.2.3]
With this feature rsync would be preferable that Robocopy.exe.
Seems to be a MSYS2-package issue as rsync doesn't seem to be in this repo
Also, you might want to report that upstream to samba https://github.com/WayneD/rsync/issues instead as that's more of their problem since we don't particularly patch it or disable it, and they seem to gate it behind the SUPPORT_CRTIMES macro which is gated by HAVE_GETATTRLIST and as far as I can tell, cygwin (msys2's base) doesn't support getattrlist()
I have created the issue here since rsync is from: https://repo.msys2.org/msys/x86_64/rsync-3.2.3-1-x86_64.pkg.tar.zst
Well, some things were made: https://github.com/WayneD/rsync/issues/194#issuecomment-876857892 https://github.com/WayneD/rsync/commit/291a042b3e6cdca6a2c48e796c9fcd2b83193311
But it looks that it requires some review and then updating the binary on repo.msys2.org.
v3.2.7 seems to be working for me:
(The textual output)
$ rsync -avN /C/backups/CNXTHDASUP.LOG /tmp
sending incremental file list
CNXTHDASUP.LOG
sent 54,469 bytes received 35 bytes 109,008.00 bytes/sec
total size is 54,344 speedup is 1.00
$ ll /C/backups/CNXTHDASUP.LOG /tmp/CNXTHDASUP.LOG
-rw-r--r-- 1 saukrs None 54344 Aug 11 2021 /C/backups/CNXTHDASUP.LOG
-rw-r--r-- 1 saukrs None 54344 Aug 11 2021 /tmp/CNXTHDASUP.LOG
$ diff -u <(stat /C/backups/CNXTHDASUP.LOG) <(stat /tmp/CNXTHDASUP.LOG) | delta --color-only --true-color always
--- /dev/fd/63 2024-02-10 11:00:31.000000000 +0200
+++ /dev/fd/62 2024-02-10 11:00:31.000000000 +0200
@@ -1,8 +1,8 @@
- File: /C/backups/CNXTHDASUP.LOG
+ File: /tmp/CNXTHDASUP.LOG
Size: 54344 Blocks: 56 IO Block: 65536 regular file
-Device: 10ff971dh/285185821d Inode: 2251799813689829 Links: 1
+Device: 10ff971dh/285185821d Inode: 31525197392139900 Links: 1
Access: (0644/-rw-r--r--) Uid: (197614/ saukrs) Gid: (197121/ None)
Access: 2024-02-10 11:00:20.871132100 +0200
Modify: 2021-08-11 22:17:49.380875500 +0300
-Change: 2023-04-15 10:40:05.030720300 +0300
- Birth: 2021-08-11 21:20:21.325334600 +0300
+Change: 2024-02-10 11:00:17.522272300 +0200
+ Birth: 2021-08-11 21:20:21.000000000 +0300
$ rsync -V
rsync version 3.2.7 protocol version 31
Copyright (C) 1996-2022 by Andrew Tridgell, Wayne Davison, and others.
Web site: https://rsync.samba.org/
Capabilities:
64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
socketpairs, symlinks, symtimes, hardlinks, no hardlink-specials,
no hardlink-symlinks, IPv6, atimes, batchfiles, inplace, append, ACLs,
xattrs, optional secluded-args, iconv, prealloc, stop-at, crtimes
Optimizations:
no SIMD-roll, no asm-roll, openssl-crypto, no asm-MD5
Checksum list:
xxh128 xxh3 xxh64 (xxhash) md5 md4 sha1 none
Compress list:
zstd lz4 zlibx zlib none
Daemon auth list:
sha512 sha256 sha1 md5 md4
rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. See the GNU
General Public Licence for details.
The only issue I see is that in Birth: seconds are truncated to an integer value (fractional part is zeroed out).
I can confirm the truncation, but it looks like the cygwin and the non-cygwin logic both use time_t, so this is a limitation of rsync and should be reported upstream.
While trying to test this I noticed that Arch/Ubuntu/Fedora all don't support --crtimes, so I haven't confirmed this on Linux.