question about tar commandForum: Programming and Scripting Topic: question about tar command started by: dtf Posted by dtf on May 04 2006,20:29
I have this little program that wakes up at 2 AM and executes a script to backup one of my drives. The script contains simple tar commands liketar uf /<backup dircertory>/<backup file> <directory to be backup> Even when I have an existing backup tar file and no new files to add to the existing tar file it can take a while to run if the tar file is large. This surprises me because I thought that all it would need to do would be to add any file with a newer time stamp than the tar file. It seems it must be doing more than that. Does any one have an idea? Is there an alternative, say with the -N option and what is the DATE format for the -N option if that is a valid alternative? Posted by NotTheMama on May 05 2006,13:57
I think the problem lies in the fact a tar file is an "Tape archive" file. As far as I know a tar file doesn't have its "meta data" at the beginning of the tar file, but at the beginning of every file in the tar file.To list the content of a tar file requires, reading the whole file. This is probably also needed for the "u" argument. I do not know exactly what tar does, but I would expect something like: has a file changed -> Yes -> append the new version, but do not delete the old. The old version is still in the tarfile, but when extracting it will automatically be overwritten by the new version at the end of the tar file. Try "tar tvf /<pathto>/<tarfile>" to view the contents of the file. Look for the entries, which are the same. If I'm correct, this process can take long because the whole file is read. |