copy file and keep creation date

hi

i have an hd with many folder, i search to copy it to my ssd but i would like to keep creation date

i tried with cp -p but creation date is not keep

thanks

The manual suggests:

Regards

susejunky

What exactly do you call “file creation date”? There is no such thing in Unix/Linux. Show command you use to display “creation date” and point at the exact place in output.

cp -a has always worked for me. Also try rsync and/or mc.

What filesystem is on your SSD?

From

man cp

-p
same as --preserve=mode ,ownership,timestamps

But I concur with @avidjaar, there isn’t a “creation date” kept in an POSIX conforming file system, thus the question of the OP is badly defined.

since kernel 4.11 or later, with glibc 2.28 or later,

ls -lt --time=birth

otherwise what is mean in kde, in dolphin if you do a right click on a file, you see created

i checked my partition i think issue is i used default partition setup of tumbleweed… it’s created a btrfs for home, before it was ext4 and i did not have this issue of created date… also not really good for performance to use btrfs

probably will need to reinstall completely

Birth time is set when file (strictly speaking, its inode) is first created and cannot be changed. Besides, it is supported only by selected filesystems (I am sure for ext4 and btrfs).

what is mean in kde, in dolphin if you do a right click on a file, you see created

No, I do not see it - I do not use dolphin.

Tried to find out what is going on here. Apart from the strange behaving Dolphin (but who believes a GUI program), I found

henk@boven:~/test> stat noot
  File: noot
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 804h/2052d      Inode: 8653509     Links: 1
Access: (0640/-rw-r-----)  Uid: ( 1000/    henk)   Gid: ( 1000/     wij)
Access: 2022-09-07 12:55:46.571181644 +0200
Modify: 2022-05-09 15:49:05.336967267 +0200
Change: 2022-09-07 12:55:45.851177053 +0200
 Birth: 2022-05-09 15:49:05.336967267 +0200
henk@boven:~/test>

So there is a “Birth” there. Must be some extra in the file system type used (ext4) above the standard POSIX requirement.
But I would warn against thinking that such an extra is implemented in all types file systems, or supported by all programs/tools.

This article explains nicely that modern filesystems like xfs, zfs, ext4, btrfs, jfs store the creation date of a file in an extra timestamp field. Ancient file system implementations which followed the old POSIX standard where not able to do this as there where only 3 timestamp fields.
https://www.baeldung.com/linux/get-file-creation-date
This implementation via filesystem inodes is indepented from any used tool/desktop environment/GUI or whatever to read this value.

But it is not possible to save this creation date if you backup/copy the files to a new drive (from hdd to ssd as example). Because the first time you write a file to a new drive this will be the creation date (on this new drive).

rsync has the option --crtime but this is not supported by the current Leap and Tumbleweed versions and i do not know any other usual command that supports this so far.
If you use an ext4 filesystem and it is really important to copy the create time you could use debugfs to set the crtime_lo/hi fields in the inode. But this falls in my opinion into the category please don’t try this at home.

As already pointed out by hcvv and in the article i linked, it is possible to get the file creation date by using stat (on modern supported filesystems) on the file.

But this was not the original question from the TO.

But,
it is answered partially by pointing out that it might not be part of all types of file systems. And the question about the type of the target file system of @mrmazda was not answered until now.

And,
Not only the article, but also the post of @avidjaar say that the file creation time is just that: the time the file is created. And of course, as long as one can write directly to the file system, because one can write directly to the container of it (device, partition, logical volume or whatever), which is normally only allowed to root, one can cheat by overwriting the bytes in the inodes.

Does the Op really want to falsify like that?

Birth refers to file creation time.

2010: Hey, whoever denounced it as stupid obviously doesn’t have the neurons to go around to be involved in the discussion. Ignore them. - Linus
2022: In this article, we covered the historical reasons for the unavailability of file creation dates, along with the methods to get the creation date on modern systems