LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Tar: Preserve file creation/modification date (https://www.linuxquestions.org/questions/linux-software-2/tar-preserve-file-creation-modification-date-726241/)

Sum1 05-15-2009 11:44 AM

Tar: Preserve file creation/modification date
 
I provide backups for users on my samba server.

1. I make a tarball of the users' directory with xz compression:
tar -cJf abc.tar.xz /abc

2. I split the tarball into 650 meg. volumes:
split -b 650m abc.tar.xz abc_vol

- - - - - - -

When I re-assemble the volumes and unpack tarball, I notice that all files and directories have lost their original creation or modification date. All dates refer to the date and time in which the archive was created.

My users often rely on searching by date to recover specific items accomplished in a chronological order.

How do I preserve the file/directory creation dates when using tar?
Does it require -atime or -mtime parameters?

All recommendations greatly appreciated.
Thank you for your time.

stress_junkie 05-15-2009 12:23 PM

UNIX and Linux do not preserve the creation date/time on files. They only preserve the last access and last modification times.

Code:

man tar
--atime-preserve
don’t change access times on dumped files

Are you restoring from backup often enough for your users to notice or are you being proactive? Being proactive is very good. Frequently restoring from backup often indicates a problem, possibly with user behavior. Backups should be the kind of thing that end users wonder why they are created because they never see the backups being used to restore files.

Sum1 05-15-2009 03:50 PM

Thanks for the quick reply, Mr. Junkie. :-)
It appears there's nothing I can do to preserve creation/modification times other than use the dd command to copy the partition.

The answer to your question is: trying to be proactive in case of the worst. Oh well, can't solve every user's problem.

Thanks again, your help is greatly appreciated.

a_q 09-29-2022 06:46 AM

Use cpio instead of tar.

On restoration, that can preserve (and reinstate) timestamps, on the files at least.

MadeInGermany 10-02-2022 12:13 PM

tar does preserve the mtime (along with ownership and permisdions).
The mtime is shown by
ls -l

If mtime is not preserved then you have a broken tar command.
Check with
tar -tvf abc.tar.xz
if the attributes are stored correctly.

As was indicated earlier, the ctime (ls -lc) cannot be preserved, because any modification of attributes updates the ctime.


All times are GMT -5. The time now is 06:48 PM.