Hello Goldmaster! o)
I registered here to give you a precise answer to your question and because most users I encountered so far, don’t really understand the problem if you try to explain the situation to them.
Many seem to mix up Modification- and Creation-Date timestamps or they never used an operating system, where you can actually work with the “Creation Date” and set it to whatever you need it to be. This is the case, if you want to pull 10 year old files from the backup e.g. and would like these 10 year old files to show as 10 year old and not as created “today”. It’s a rather simple and obvious thing. Being able to set the “Creation-Date” is common standard for 30+ years on other operating systems.
So, no, unfortunately you cannot really change the “Creation-Date” or “Birth-Date” of files or folders on BTRFS timestamps or on any other file system on Linux. The Linux kernel has no interface / function to do this.
The only (bad) option you have is:
Write a custom tool / script, which will adjust the system time for each file you copy, so that “when the copy is created” it matches the original creation time. Yes, this is a hack. I don’t know what your “cron” jobs will do if the system date jumps back and forth or what your updating daemon will do. So, I can’t really recommend this approach, I spent multiple days researching this problem, trying to find a way around it, but there is no other (for BTRFS at least).
There is another hack, using “debugfs”, but which only works for EXT4, I did not try this, I’m not interested in using a file system without compression and no other “bells and whistles”.
It seems you can use “btrfs send / receive” to preserve all the time stamps, but this only allows to restore a full snapshot, not individual files and won’t work if you want to you copy files from any “non-BTRFS” location.
If anybody knows better about the “Creation-Date” problem, please share your knowledge!
Thank you in advance! o)
–
Some background information here and some brain storming on how to resolve the problem.
You can read about a discussion and kernel / btrfs file system developers discussing this topic here in the year 2019. That patch never made it into the kernel and no other solution was provided.
The theoretical solution #1 (from my perspective):
Convince the kernel / btrfs file system developer(s) to change their mind about being able to change the “Creation Date” from the user space (very unlikely to happen).
The theoretical solution #2 (from my perspective):
Convince the kernel / btrfs file system developers to at least automatically write an “extended attribute” (xatt) to every file created on the system. Let’s call it “user.date_created”. This attribute would allow to be changed by you, whenever you want.
But:
This will not solve the problem “instantly”, because no Linux software right now will read and use that “user.date_created” attribute and allow you to list your files by your “real” creation date. This would need broader adoption and hundreds of tools would need to adapt their code to support this “extended attribute”. You also want tools to offer the user a choice about what “Creation Date” he likes to use, the file system owned one or the one you have control over.
So, you probably want “ls” to list your files on the terminal by the newly introduced “user.date_creation” attribute instead of “Birth” - owned by the file system, You also want “rsync”, Dolphin, Thunar, Nemo and all the other basic file managers to offer a column “Creation Date (User)” besides the already existing “Creation Date” provided by BTRFS and other file systems.
Is any of this going to happen within the next 10 or 20 years? I doubt it.
Without the support for this new attribute, the new attribute is useless in day to day work, but you could at least migrate / copy some files into Linux and preserve the creation date in that attribute.
I’m in the same boat as you. I have a 30 year history of “Creation Dates” with Windows and the NTFS file system. The moment I copy this over to a Linux machine, I have data-loss. “Meta-data loss” to be specific and it is obvious, that I am not going to do this without a proper solution or standard to handle “Creation Date” as “we” need it.