I'm looking for a way to copy files while ensuring that all their attributes, especially the creation and modified timestamps, are preserved. For instance, if I have a file on an ExFAT drive with a creation time of 12:34:56.78, I want the copied file on the destination drive to maintain that exact timestamp down to the millisecond. Any tips on how to achieve this?
4 Answers
Try the `cp -a source-file destination-file` command. It should help you maintain the attributes during the copy process, but make sure to check the specific behaviors on different file systems.
Keep in mind that preserving creation time can be tricky, especially with filesystems like ext4 or btrfs. There are hacks available, like using `debugfs`, but they can be complicated. Also, I’ve found that copying between ExFAT drives sometimes doesn’t keep the creation time either. Offers no easy solutions depending on the file systems involved.
You can use the `rsync` command for this purpose. It does a great job of preserving most attributes of files, including timestamps.
If you're focused solely on the timestamps, maybe you should consider moving instead of copying. That way, you won't have to worry about it.
Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures