LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 06-24-2006, 04:33 AM   #1
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Rep: Reputation: 56
About compressed tarball


Hi folks,

I create a tarred file then compressed with bzip with following command line;

# tar -jcpf AAA.bz2 /home/path/to/dirA

dirA is about 2G in size.

After working several days on dirA I want to create a new compressed tarred file. Instead of repeating the above command, is there a way starting from the old file AAA.bz2 making use of the options -u, -N, -G, etc. to reduce the compressing time? I looked around on man tar and Internet and could not sort out their combination on the command line.

Could you please shed me some light. TIA

B.R.
satimis
 
Old 06-24-2006, 06:40 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

To my knowledge the -j (bzip2) and the -u (update) option will not work together (archive is compressed by the -j option).

This is one solution:

You can use the command you used to create the compressed archive. To update the archive you can do the following:

bunzip2 AAA.bz2 ; tar -upf AAA tst/ ; bzip2 AAA

Hope this helps.
 
Old 06-24-2006, 07:09 AM   #3
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Hi druuna,

Tks for your advice.

Quote:
You can use the command you used to create the compressed archive. To update the archive you can do the following:

bunzip2 AAA.bz2 ; tar -upf AAA tst/ ; bzip2 AAA
Please explain in more detail:

1) The old file is AAA.bz2. What is the function of this command "tar -upf AAA tst/ "

2) What is tst/

3) Is it AAA the new compressed tarball?

4) Where is the path to /home/path/to/dirA

5) Will the subdirs and files deleted on dirA also be removed on the new compressed tarball?

TIA

B.R.
SL
 
Old 06-24-2006, 07:39 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

The tst part is a leftover from my testing, that should be /home/path/to/dirA in your example. Sorry about that

I did use your example as a start, more elegant (and maybe clearer) would be:

tar -jcpf AAA.tar.bz2 /home/path/to/dirA to archive and comress the file (first instance). The only difference between your original command and this one is the name of the compressed archive (AAA.bz2 vs AAA.tar.bz2).

to update:

bunzip2 AAA.tar.bz2 ; tar -upf AAA.tar /home/path/to/dirA ; bzip2 AAA.tar

The first command uses the -j option to compress (using bzip2) the archive.
The second command uncompresses, using bunzip2, the compressed tarball (which leaves you with AAA.tar), after that the tarball is updated using the -u option and compressed again using bzip2.

Tar and/or bzip2 do not delete the original files/dirs that are archived. bzip2 will remove the archive (AAA.tar) and replace this with the compressed archive (AAA.tar.bz2).

Hope this clears things up a bit.

Last edited by druuna; 06-24-2006 at 07:40 AM.
 
Old 06-24-2006, 10:56 AM   #5
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Hi druuna,

Tks for your advice.

Tested the command line, but still having some problem. Steps performed as follows;

1) untar the old-compressed tarball
$ tar -jxpf AAA.bz2
$ ls
AAA.bz2 old-dirA

2) deleted the old-compressed tarball
$ rm AAA.bz2

3) created a new old-compressed tarball again and removed old-dirA
$ tar -jcpf AAA.tar.bz2 old-dirA/
# rm -rf old-dirA

4) ran the command line recommended
$ bunzip2 AAA.tar.bz2 ; tar -upf AAA.tar /home/path/to/new-dirA ; bzip2 AAA.tar

5)
$ ls
AAA.tar.bz2

6) untar the new-compressed tarball
$ tar -jxpf AAA.tar.bz2

It was found that the old-dirA and the new-dirA co-existing. I don't need to retain the old-dirA in the new-compressed tarball.


Furthermore can I create a new-compressed tarball in another name.
e.g. old-compressed tarball=AAA_20060614.tar.bz2 (old date indicated)
new-compressed tarball=AAA_20060624.tar.bz2 (new date indicated)

Besides, not much time saving.

TIA

B.R.
satimis

Last edited by satimis; 06-24-2006 at 11:01 AM.
 
Old 06-24-2006, 11:17 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

To my knowledge you cannot remove files from an archive that are no longer present (using tar options), the -u option adds/updates files, it does not remove files from the archive.

This, together with your second question (different names for each [compressed]archive), leads me to believe that you should archive the directory in question completely. It's 'only' 2 Gb.

It's up to you to decide what works better:

1) multiple compressed archives (which could lead to a situation that you need some files from one archive and some from another archive)

2) one archive. All files together in one compressed archive.
 
Old 06-25-2006, 08:39 AM   #7
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Hi druuna,

Tks for your advice.

I think "tar" will not be the right tool for my application.

Acturally my need is not complicate:-

1) Just backup the working data files in a directory on /home.
2) The compressed files can be restored to another HD on another PC, not only on the original PC.
3) The compressed files can be read without restore
4) In order to reduce the time in creating another backup, the second backup will base on the original compressed files.

Have you had any suggestion? Can folks on the forum shed me some light? TIA

B.R.
SL
 
  


Reply



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
Compressed Albums balayhashi Linux - Software 2 11-10-2005 02:46 PM
Knowing the extracted size of compressed tarball without extracting kushalkoolwal Programming 2 11-05-2005 07:10 PM
Compressed Root Disk MadnessASAP Linux - Software 0 07-29-2005 07:05 PM
compressed printing dreamsshinu Linux - Software 2 12-23-2004 09:51 AM
using compressed kernel blistfix Linux - Newbie 2 08-22-2001 10:12 AM

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

All times are GMT -5. The time now is 07:13 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