GNU tar
Creation time:
Linux doesn't really record file creation time. It has the ctime
timestamp, which is sometimes mistaken for creation time, but that is actually "inode change time": it records the last time there was a change to either the file or its permissions, owner, etc. Ie. it changes more often than mtime
. The ctime
stamp is handled by the kernel, and can't be set to arbitrary values by the user (although you can reset it to the current time easily enough).
Modification time:
mtime
is preserved by tar
Access time:
tar
normally changes the access time even on the original file. You can prevent this using the --atime-preserve
flag. You may also want the --preserve
tag which preserves permissions (and also directory sorting order).
I don't know if you can make tar
preserve atimes on the archived files, but you could always fix those by:
- Untarring
- Using
touch -a -d TIME FILE
on each file (with the time in format [[CC]YY]MMDDhhmm[.ss]
)
- Re-tarring with
tar --atime-preserve
warning: Using --atime-preserve
currently remembers the atime so it can preserve it after reading it. On most systems, this will cause the ctime to change, which can sometimes interfere with other software (eg. security software).
Other software
You might look into rsync
(see this article for example) or a version control system (like git
)