Anyone know how to copy a folder, keeping the creation date of the original?
Page: 1/2»
  Go to:
Comandante Ñoñardo May 28, 2021
I want to copy a folder with my Lutris games, and I want to keep all the timestamps (creation date and modification date) and ownership of the Folder, subfolders, symlinks and files.
damarrin May 28, 2021
rsync? Or compress it, that should preserve dates and times.

Last edited by damarrin on 28 May 2021 at 7:08 pm UTC
tuubi May 28, 2021
Good old `cp -a` (or --archive) should do the trick. Check the man page for more info.
Comandante Ñoñardo May 28, 2021
Quoting: tuubiGood old `cp -a` (or --archive) should do the trick. Check the man page for more info.
That command keep the modification date, but not the creation date..

I need the copy to be a perfect clon.
tuubi May 28, 2021
Quoting: Comandante Ñoñardo
Quoting: tuubiGood old `cp -a` (or --archive) should do the trick. Check the man page for more info.
That command keep the modification date, but not the creation date..

I need the copy to be a perfect clon.
Sorry, I don't know a way around that beyond cloning the whole file system. Archiving, rsyncing or whatever won't help you there. The file system updates the ctime whenever an inode is changed in any way, and as far as I know the Linux kernel doesn't have a mechanism for overriding this behaviour.

I don't think Lutris cares about ctimes though, so I guess you have some other reason to worry about it.
Lachu May 29, 2021
Use cp -p

From manual page:
-p implicts --preserve=mode,ownership,timestamps

It's my translation to English, so sorry it was wrong. I have localized manuals.
Lachu May 29, 2021
Of course,

--preserve=timestamps should also do the trick.
Lachu May 29, 2021
Also
cp -pP

It will copy symbolic links content instead location it points to. The -P do the trick.

From manual
-P, --no-dereference
never travel through symbolic links in source
tuubi May 29, 2021
I suggested `cp -a` earlier, and it already implies --preserve=all. But there's no way to make cp preserve the ctime timestamp.
Comandante Ñoñardo May 30, 2021
Quoting: tuubiI suggested `cp -a` earlier, and it already implies --preserve=all. But there's no way to make cp preserve the ctime timestamp.

And If I play with the system time before making the copy?

What is more fast? The use of cp or Rsync?
denyasis May 30, 2021
I think, for this case, rsync and cp would be about the same. Rsync's advantages are that it can compress over a network and that it can "update", skipping unchanged files that already exist in the destination directory.

Unless your doing one of those things, I find them to be about the same in terms of speed.

Quoting: Comandante ÑoñardoAnd If I play with the system time before making the copy?

That's a clever idea! Although, wouldn't you have to alter the system time for every file just before you copy it to ensure every file has the same time as the old? I wonder if that's is scriptable in bash?

I can't remember what is called exsctly, but I think you might want to consider disabling the NTP deamon/service thing so the system doesn't automatically "fix" and resync to the correct time in the middle of you work. Or take the computer in question off the internet. Prolly easier to disconnect.
While you're here, please consider supporting GamingOnLinux on:

Reward Tiers: Patreon. Plain Donations: PayPal.

This ensures all of our main content remains totally free for everyone! Patreon supporters can also remove all adverts and sponsors! Supporting us helps bring good, fresh content. Without your continued support, we simply could not continue!

You can find even more ways to support us on this dedicated page any time. If you already are, thank you!
Login / Register


Or login with...
Sign in with Steam Sign in with Google
Social logins require cookies to stay logged in.

Buy Games
Buy games with our affiliate / partner links: