1

I’ve recently decided to archive some data using Tar. The data consists of numerous backups of the same folder; meaning that it contains a lot of duplicates. I read that because Tar lacks an index, it doesn’t work well with data that contains many duplicates. So basically my question is would Tar be suitable for archiving such data?

I care mostly about preserving all the original data in an archive, this includes all the file timestamps: creation, modification, access.

7
  • @Ramhound I have tried with 7-zip in Windows, without success, but I haven't tried using GNU tar in Linux. Is tar incapable of storing timestamps, other than the modification date?
    – user404162
    May 22, 2015 at 18:19
  • @Ramhound Yes, I told you already that I have done it with 7-zip, and I failed to retain dates other than the modification, however I have not tried with GNU tar yet. Perhaps the latter will yield a different result.
    – user404162
    May 22, 2015 at 18:29
  • @ramhound What I meant in my first response, was that I did try your method on Windows. I have not said that I will be using it on a particular OS.
    – user404162
    May 22, 2015 at 18:42
  • I read your question as, since you linked to the GNU manual command, it was sort of implied you would be using GNU. rsync & data corruption.
    – Ramhound
    May 22, 2015 at 18:46
  • @ramhound I'm sorry, I did not link to GNU tar in my question. The editor must've done that.
    – user404162
    May 22, 2015 at 18:49

2 Answers 2

2

Of course Tar can archive these backups, no matter how many duplicates you have in there. If you have 100 duplicates of file abc.doc in 100 different folders, it will be archived 100 times. That said, it is not efficient.

If a backup tool can de-duplicate data, it would recognize those 100 identical files, backup one, and reference it 99 times. If one of those version changes, it will remove the reference, and back it up seperately.

1
  • If you have a single tar archive file to which you make numerous updates, the changed files are appended to the archive, rather than replacing their earlier versions.
    – mpez0
    May 22, 2015 at 18:50
0

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:

  1. Untarring
  2. Using touch -a -d TIME FILE on each file (with the time in format [[CC]YY]MMDDhhmm[.ss])
  3. 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)

You must log in to answer this question.