4

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?

QDelage
  • 41

1 Answers1

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.

JRFerguson
  • 14,740
  • 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...) – QDelage Oct 03 '22 at 10:14
  • Related: https://unix.stackexchange.com/questions/636160/why-rsync-on-linux-does-not-preserve-all-timestamps-creation-time – JRFerguson Oct 03 '22 at 11:26