4

I am using the current rsync 3.2.3 version and when I run stat command it shows me this info for my file.

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

I want to preserve Access, Modify and Birth timestamps. Use this command in rsync

rsync --atimes --times --crtimes 

or

rsync -UtN

The problem creation time (--crtimes) is not preserved on Linux. It automatically sets to the current transfer time.

How can I change the behaviour on Linux? I want to preserve all 3 timestamps for my copied files and folders.

If I do the same on macOS it works without problems.

EDIT

On macOS 10.13 and macOS 11 I just need to install homebrew and then I can get the latest rsync 3.2.3. By default, macOS has a very outdated rsync version 2.6.9 integrated.

  1. Open Terminal

  2. Install Homebrew

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

  3. Install rsync

    brew install rsync

8
  • 1
    What filesystem are you using on the Linux system?
    – Kusalananda
    Feb 24 at 13:27
  • ext4 and Btrfs on the Linux system.
    – Olea.2fmao
    Feb 24 at 13:28
  • 1
    @Olea.2fmao Do you mean rsync from ext4 to btrfs (cross file system), or from ext4 to ext4 and from btrfs to btrfs (same file system), where both same FS tries fail.
    – Pro Backup
    Feb 24 at 14:12
  • ext4 to ext4, ext4 to Btrfs, Btrfs to Btrfs and Btrfs to ext4 The creation time is not preserve and it is set to the current transfer time.
    – Olea.2fmao
    Feb 24 at 14:19
  • Does this help? unix.stackexchange.com/questions/61586/… Feb 24 at 15:29
1

The problem creation time (--crtimes) is not preserved on Linux. It automatically sets to the current transfer time.

While you can perfectly query crtime, there's no API to set it in Linux unfortunately: https://linux.die.net/man/2/utimes .

How can I change the behaviour on Linux? I want to preserve all 3 timestamps for my copied files and folders.

Check this question: Copying or restoring crtime for files/directories on ext4fs filesystem

0

Linux

crtime tells when the file was created in this filesystem. It was never intended to indicate when the content might have been created somewhere else.

MacOS

rsync can be "patched" on MacOS. If you compile rsync with the patches fileflags, crtimes, hfs-compression then rsync can handle OS X metadata and preserve the original file's birthtime on the new file. Note that st_birthtime is only available in the 64 bit inode variants. See man 2 stat.

It's possible there are patched versions of rsync for Linux around. Though I am not aware of any.

2
  • On my macOS 10.13 and macOS 11 I just need to install homebrew and then I can get the latest rsync 3.2.3. By default, macOS has a very outdated rsync version 2.6.9 integrated. Install Homebrew /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" Install rsync brew install rsync
    – Olea.2fmao
    Feb 24 at 15:59
  • Then on macOS I can preserve all 3 timestamps (Access, Modify and Birth), on Linux only Birth does not work.
    – Olea.2fmao
    Feb 24 at 16:02

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.