为什么 Linux 上的 rsync 不保留所有时间戳(创建时间)?

Ole*_*mao 8 linux rsync file-copy timestamps macos

我正在使用当前的 rsync 3.2.3 版本,当我运行stat命令时,它会显示我的文件的此信息。

stat '/test.txt'
File: /test.txt
Size: 0     Blocks: 0
IO Block: 4096   regular empty file
Device: fd00h/64768d    Inode: 11949
Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/liveuser)   Gid: ( 1000/liveuser)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2021-02-24 03:17:27.142676494 +0100
Modify: 2021-02-24 03:17:27.142676494 +0100
Change: 2021-02-24 03:17:27.142676494 +0100
Birth: 2021-02-24 03:17:27.142676494 +0100
Run Code Online (Sandbox Code Playgroud)

我想保留访问、修改和出生时间戳。在 rsync 中使用此命令

rsync --atimes --times --crtimes 
Run Code Online (Sandbox Code Playgroud)

或者

rsync -UtN
Run Code Online (Sandbox Code Playgroud)

Linux 上不保留问题创建时间 (--crtimes)。它会自动设置为当前传输时间。

如何更改 Linux 上的行为?我想保留复制的文件和文件夹的所有 3 个时间戳。

如果我在 macOS 上做同样的事情,它就可以正常工作。

编辑

在 macOS 10.13 和 macOS 11 上,我只需要安装 homebrew,然后就可以获得最新的 rsync 3.2.3。默认情况下,macOS 集成了非常过时的 rsync 版本 2.6.9。

  1. 打开终端

  2. 安装自制程序

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

  3. 安装rsync

    brew install rsync

Pro*_*kup 6

Linux

crtime告诉文件何时在此文件系统中创建。它从来没有意图表明内容可能是在其他地方创建的。

苹果系统

rsync可以在 MacOS 上“修补”。如果rsync使用补丁 fileflags、crtimes、hfs-compression 进行编译,则rsync可以处理 OS X 元数据并在新文件上保留原始文件的出生时间。请注意,st_birthtime仅在 64 位 inode 变体中可用。看man 2 stat

可能有rsync针对 Linux 的修补版本。虽然我什么都不知道。