compress/decompress don't take you back to the same file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers compress/decompress don't take you back to the same file
# 1  
Old 02-02-2009
Question compress/decompress don't take you back to the same file

Hi there,
I have a file system.tgz. I want to make changes inside this archive but before that, I want to be sure I recompress it in the exact same format.
So I did the following:
Code:
me:~# # Duplicate the archive ---------------------------------
me:~# cp system.tgz system.01.tgz
me:~# ls -l system.tgz system.01.tgz
-rw-r--r-- 1 root root 274650447 2009-02-02 22:41 system.01.tgz
-rw-r--r-- 1 root root 274650447 2009-02-02 21:32 system.tgz
me:~#
me:~# # Unzip the archive -------------------------------------
me:~# mkdir system.01/
me:~# tar -zxf system.01.tgz -C system.01/
me:~#
me:~# # Rezip the archive -------------------------------------
me:~# cd system.01/
me:~/system.01# tar -zcf system.01.tgz *
me:~/system.01# mv system.01.tgz ../
me:~/system.01# cd ..
me:~#
me:~# # Compare with previous archive -------------------------
me:~# ls -l system.tgz system.01.tgz
-rw-r--r-- 1 root root 274642873 2009-02-02 22:54 system.01.tgz
-rw-r--r-- 1 root root 274650447 2009-02-02 21:32 system.tgz

As you can see, the archive is not exactly as it was. Maybe I'm not using the same compression level? But I have no idea how to set this parameter.
Thanks for your help.
Santiago
# 2  
Old 02-02-2009
Hi,
without analysing it too much,
have You examined that the pathnames stored in the files are the same? If You change the name of a directory it is compressed from it will affect the compression since size and sequence of characters differ and pathnames are stored in the compressed file.
Just a thought.

/Lakris
# 3  
Old 02-02-2009
Thanks Lakris,
I forgot to mention it but yes, I launched my command so that they contain exactly the same.
Code:
me:~# tar -tvf system.tgz | head
drwxr-xr-x root/root         0 2008-11-07 14:39 ./
drwxr-xr-x root/root         0 2008-11-20 09:00 ./root/
-rw------- root/root       150 2008-07-30 17:36 ./root/.serverauth.2612
drwxr-xr-x root/root         0 2008-09-16 09:11 ./root/.subversion/
-rw-r--r-- root/root      4277 2008-08-12 14:13 ./root/.subversion/README.txt
-rw-r--r-- root/root      3270 2008-08-12 14:13 ./root/.subversion/servers
-rw-r--r-- root/root      4731 2008-08-12 14:13 ./root/.subversion/config
drwx------ root/root         0 2008-09-16 09:11 ./root/.subversion/auth/
drwxr-xr-x root/root         0 2008-09-16 09:11 ./root/.subversion/auth/svn.simple/
-rw-r--r-- root/root       172 2008-08-12 14:13 ./root/.subversion/auth/svn.simple/1e514a6123873f77e37a03950f1eabf6
me:~#
me:~# tar -tvf system.01.tgz | head
drwxr-xr-x root/root         0 2008-11-07 14:39 ./
drwxr-xr-x root/root         0 2008-11-20 09:00 ./root/
-rw------- root/root       150 2008-07-30 17:36 ./root/.serverauth.2612
drwxr-xr-x root/root         0 2008-09-16 09:11 ./root/.subversion/
-rw-r--r-- root/root      4277 2008-08-12 14:13 ./root/.subversion/README.txt
-rw-r--r-- root/root      3270 2008-08-12 14:13 ./root/.subversion/servers
-rw-r--r-- root/root      4731 2008-08-12 14:13 ./root/.subversion/config
drwx------ root/root         0 2008-09-16 09:11 ./root/.subversion/auth/
drwxr-xr-x root/root         0 2008-09-16 09:11 ./root/.subversion/auth/svn.simple/
-rw-r--r-- root/root       172 2008-08-12 14:13 ./root/.subversion/auth/svn.simple/1e514a6123873f77e37a03950f1eabf6

# 4  
Old 02-02-2009
Ok, well that was just my first idea, that since tar contains META information, there are a lot of thing that could affect the final size of an archive. I wouldn't trust tar size alone as the criteria.
Are the files created with the same version of tar?
/L
# 5  
Old 02-02-2009
Thanks Lakris,
You are right. I knew very few about tars before I had this problem.
So I explored in details the content of the archives using
Code:
tar -tvf system.tgz > system.lst
tar -tvf system.01.tgz > system.01.lst
diff system.lst system.01.lst

1) Path, attributes and size are strictly identical before and after decompression/recompression.

2) Dates can be different:
- regular files, block and character devices, hard links and named pipes always keep the same date
- symbolic links never keep the same date. Actually they get the current time of decompression.
- I was not able to build any theory about directories

3) Owners are different in some cases. I assume that only UID/GID is kept for the owner. So if the archive comes from another system (which is my case), UID/GID can result in a different username/groupname.

If anyone has serious knowledge about tars, can he/she confirm what I said?
Can this explain the difference between the original archive and the one resulting of a decompression/recompression?

Thanks for your help
Santiago
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Tar to decompress and to convert file to .dat format

tar -tvf abc.tar.gz gives me the file name abc.Is it possible to rename the file to abc.dat while decompressing using tar ? Thanks. (2 Replies)
Discussion started by: vedanta
2 Replies

2. UNIX for Dummies Questions & Answers

Please, I want to decompress a file.bin "firmware"

Please, help me Please, I want to decompress a file firmware for a 2000 SAT HD Please note that I use Version ubuntu 10.04 lts file name : .................. NxpRom.bin .................. Or How do I use and is... (0 Replies)
Discussion started by: samy2012
0 Replies

3. Shell Programming and Scripting

Decompress (with gunzip) recursively, but do not delete original gz file

Hi all, I have a folder hierarchy with many gz files in them. I would like to recursively decompress them, but keep the original files. I would also like to move all the decompressed files (these are very large HDF5 files with .CP12 extension) to another data folder. Currently I am using four... (3 Replies)
Discussion started by: gansvv
3 Replies

4. UNIX for Dummies Questions & Answers

Issue: Compress in unix server and FTP to windows and open the compress file using Winzip

Hi All ! We have to compress a big data file in unix server and transfer it to windows and uncompress it using winzip in windows. I have used the utility ZIP like the below. zip -e <newfilename> df2_test_extract.dat but when I compress files greater than 4 gb using zip utility, it... (4 Replies)
Discussion started by: sakthifire
4 Replies

5. UNIX for Dummies Questions & Answers

Using gunzip to decompress .zip file

Hi, I have a zipped Oralce software (linux.x64_11gR1_database.zip) and I need to unzip it. On the Linux server, I only see the gunzip utility listed: $ ls -ltr *zip* -rwxr-xr-x 3 root root 60320 Jan 15 2008 gzip -rwxr-xr-x 3 root root 60320 Jan 15 2008 gunzip Can I use the command... (1 Reply)
Discussion started by: syang68
1 Replies

6. Shell Programming and Scripting

unix script to takes the old data from a TXT file and compress them into new file

Hi, I am looking for the unix script which can takes the 2 month old data from a TXT file (there is one txt file in whiche messages are appended on daily basis) and compress them into new file.Please halp me out. (2 Replies)
Discussion started by: vpandey
2 Replies

7. UNIX for Dummies Questions & Answers

Decompress a .SP file

Hi to all, I'm new in this forum and I just need a quick answer from the experts out there, I have a 2761.sp file, in short a ".SP" file, it was given to me compressed, and I need to decompress it before Monday. I saw a software named Splint, but it shows an error, a DMI error message, so I dont... (3 Replies)
Discussion started by: jeco
3 Replies

8. UNIX for Advanced & Expert Users

compress more than one file

hi, I need to compress a couple files in a directory.i tried using tar cvf filename1 filename2 but i am not able to open tar file. please suggest how to compress more than one file in to same file thanks in advance (2 Replies)
Discussion started by: prasee
2 Replies

9. UNIX for Dummies Questions & Answers

[help] Cant compress file

Anybody know what happened here? 162 lab2-36:~/try_direct/another> compress url.txt url.txt: -- file unchanged (8 Replies)
Discussion started by: endeavour1985
8 Replies
Login or Register to Ask a Question