6

I need to copy files and preserve all their metadata, including creation date.

I found ways to use rsync options to preserve modification date, but I also need the creation date to be the same, and not depending on when I copy the files.

Is there a way to do so? With a utility or any other way?

Maybe I could do it programmatically?

2
  • 2
    Brith/creation time like change-status time on Linux is not meant to be tampered with. But then again, see Change file creation date and time based off of file name for a way to trick your system. Commented Oct 3, 2022 at 13:10
  • Also beware that that birth time is rarely useful as it doesn't tell you when the contents of the file was created nor even when a file with that name appeared in a directory. Commented Oct 3, 2022 at 13:14

1 Answer 1

4

If your destination filesystem supports creation (birth) time metadata, using an rsync version (3.1.1 or later) that supports the crtimes option achieves what you want.

--crtimes, -N

This tells rsync to set the create times (newness) of the destination files to the same value as the source files.

Update:

While this works flawlessly on macOS, with Linux this isn't supported. See here.

2
  • Well, I don't know about the filesystems, but the outputs states my version does not support it "v3.2.6" (I tested it with Arch and with FreeBSD with the v3.2.5...) Commented Oct 3, 2022 at 10:14
  • 1
    Related: unix.stackexchange.com/questions/636160/… Commented Oct 3, 2022 at 11:26

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.