LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-15-2009, 11:44 AM   #1
Sum1
Member
 
Registered: Jul 2007
Distribution: Fedora, CentOS, and would like to get back to Gentoo
Posts: 332

Rep: Reputation: 30
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.
 
Old 05-15-2009, 12:23 PM   #2
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
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.

Last edited by stress_junkie; 05-15-2009 at 12:26 PM.
 
Old 05-15-2009, 03:50 PM   #3
Sum1
Member
 
Registered: Jul 2007
Distribution: Fedora, CentOS, and would like to get back to Gentoo
Posts: 332

Original Poster
Rep: Reputation: 30
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.
 
Old 09-29-2022, 06:46 AM   #4
a_q
LQ Newbie
 
Registered: Sep 2022
Posts: 1

Rep: Reputation: 0
Use cpio instead of tar.

On restoration, that can preserve (and reinstate) timestamps, on the files at least.
 
Old 10-02-2022, 12:13 PM   #5
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,761

Rep: Reputation: 1187Reputation: 1187Reputation: 1187Reputation: 1187Reputation: 1187Reputation: 1187Reputation: 1187Reputation: 1187Reputation: 1187
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.

Last edited by MadeInGermany; 10-02-2022 at 12:21 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Get file modification date/time in Bash script cmfarley19 Programming 16 04-15-2015 06:25 PM
file creation date prashantbhushan Linux - General 2 05-29-2007 08:32 AM
Heeelp! How to preserve file date modification attribute Slackovado Slackware 1 03-30-2005 09:36 AM
ls -al file creation date blackzone Linux - Newbie 2 08-23-2004 01:31 AM
File Modification Date Comparison MadTurki Programming 7 03-08-2004 04:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration