Facing issues with tar and gzip !


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Facing issues with tar and gzip !
# 1  
Old 07-09-2012
Facing issues with tar and gzip !

Hi,
I am trying to :-
(1.) Tar the file and then
(2.) Gzip it !

HTML Code:
Tar command :-
 
tar -cvf BLUESTAR_Archive.log_$(date +%y_%m_%d_%H_%M).tar  /app/local/XXX/XXX/XXX/logs
 
 
Gzip command :-
 
Gzip  /app/local/XXX/XXX/XXX/logs/BLUESTAR_Archive.log_$(date +%y_%m_%d_%H_%M).tar 
 
Bothe of these commands are working fine but the problem is regarding the file size.

After doing the tar and gzip operation the size of the file keeps on increasing which is expected to be less or same as the previous gzip files.

HTML Code:
Extract :-
 
-rw-r--r--  173471   Jul  9 13:03 BLUESTAR_Archive.log.log_12_07_09_13_03.tar.gz
-rw-r--r--  318456   Jul  9 13:14 BLUESTAR_Archive.log.log_12_07_09_13_14.tar.gz
-rw-r--r--  1031131 Jul  9 13:15 BLUESTAR_Archive.log.log_12_07_09_13_15.tar.gz
-rw-r--r--  1523045 Jul  9 13:16 BLUESTAR_Archive.log.log_12_07_09_13_16.tar.gz
-rw-r--r--  3020915 Jul  9 13:18 BLUESTAR_Archive.log.log_12_07_09_13_18.tar.gz
 
The size of the parent file doesn’t increase beyond 2000000 !!!!!

I am not able to understand that why the size of the files after gzip keeps on increasing when the size of the parent file doesn’t increase beyond 2000000 !!!!

When I delete the older logs the gzip again starts behaving in the same fashion i.e the 1st file of less size and gradually the size of files increases like the above one .
I am very surprised by this behavior !

Could anyone please help me to understand the problem or is there something wrong with my logic or way of doing it !!!!

Is there any other command similar to tar and gzip ??

Please help.

Regrads.

Last edited by acidburn_007; 07-10-2012 at 04:24 AM..
# 2  
Old 07-09-2012
Why are you surprised? You are archiving all the same logs over and over. Naturally your archives get bigger over time, the later files hold all the old files plus newer ones.
# 3  
Old 07-09-2012
Your archives are under /app/local/XXX/XXX/XXX/logs so they they get included in the tar archive ! The more times you run it, the bigger it gets.
# 4  
Old 07-09-2012
hey Methyl & Corona688 thanks a lot for the prompt reply !!


Could you please let me know the way. So that the tar archieve doesn't gets included and which in turn doesn't increase the file size !

Please let me know the way/ solution to resolve this issue.

What modifications needs to be done in the script so that this type of problem doesn't occurs !!!


Thanks in advance !

---------- Post updated at 09:16 PM ---------- Previous update was at 09:08 PM ----------

An update !

After taking the backup of the parent file. I run the following command to make the parent file of size 0 :-

HTML Code:
 
cat /dev/null > BLUESTAR_Archive.log
 
What I am confused at is that after taking the backup and making the parent file contents nill i.e. size 0 !!!

Then also after ding the tar and gzip task on a file. The file size still keeps on increasing !!!

I don't understand why this is happening ??

Last edited by acidburn_007; 07-10-2012 at 04:41 AM..
# 5  
Old 07-09-2012
Run this command and check whats is getting tarred!!

Code:
tar -tvf <tar_file>

# 6  
Old 07-10-2012
Hi Zedex,

Thanks for the post !

I tried using :-


Code:
 
tar -tvf <tar_file>


After executing it. All the list of the backup log files were displayed. The size of the file doesn't got reduced. Like before it is again doing the tar and gzip operation on the already done files and because of that the size of the backup file is increasing !!!

---------- Post updated at 01:08 PM ---------- Previous update was at 12:39 PM ----------

Hi,
Please let me explain my requirement and the bottleneck!
My Requirement:-
In our main file BLUESTAR_Archieve.log the logs gets appended every day.
So, we are required to take the back-up of the log files daily based on timestamp.
For this I have written a script :-
Code:
 
#!/bin/ksh
# A shell script ------------------------------------------------------------------
cd /app/local/XXX/XXX/XXX/logs
 
find BLUESTAR_Archieve.log -exec cp {} BLUESTAR_Archieve.log _$(date +%y_%m_%d_%H_%M) \;
 
tar –cvf BLUESTAR_Archieve.log _$(date +%y_%m_%d_%H_%M).tar /app/local/XXX/XXX/XXX/logs
 
gzip /app/local/XXX/XXX/XXX/logs/ BLUESTAR_Archieve.log _$(date +%y_%m_%d_%H_%M) 
 
mv BLUESTAR_Archieve.log _$(date +%y_%m_%d_%H_%M) .tar.gz /app/local/XXX/XXX/XXX/logs /LogsBackup
 
rm –f /app/local/XXX/XXX/XXX/logs / BLUESTAR_Archieve.log _$(date +%y_%m_%d_%H_%M)
 
cat /dev/null > BLUESTAR_Archieve.log

Problem :-
The script is running fine.
But when I checked the back-up log files. The size of the files are increasing :-
HTML Code:
-rw-r--r-- 1734571 Jul 9 10:03 BLUESTAR_Archive.log.log_12_07_10_10_03.tar.gz
-rw-r--r-- 3318456 Jul 9 10:10 BLUESTAR_Archive.log.log_12_07_10_10_10.tar.gz
-rw-r--r-- 12031131 Jul 9 10:15 BLUESTAR_Archive.log.log_12_07_10_10_15.tar.gz
-rw-r--r-- 41523045 Jul 9 10:26 BLUESTAR_Archive.log.log_12_07_10_10_26.tar.gz
-rw-r--r-- 66620915 Jul 9 10:38 BLUESTAR_Archive.log.log_12_07_10_10_38.tar.gz
 

After getting the post from fellow members. I came to realize that the tar and gzip are performing the action on the files on which this action had already been performed.
I tried the below command also :-
Code:
Tar –tvf <tar_file >



But this is displaying all the files in the BackupLogs !!!

Is there any way around. So, that the tar and gzip don’t perform the same operations on the already performed files.
I don't need the tar and gzip to perform the same action on the already done files. Instead it should be doing the tar and gzip action only on new files !
Please suggest/ help !

Thanks

Last edited by acidburn_007; 07-10-2012 at 04:43 AM..
# 7  
Old 07-10-2012
Of course it gets larger!

Day 1: you archive today.og
day 2: you archive yesterday.log, today.log
day 3: you archive 2 days ago.log, yesterday.log, today.log
...and so on.

This is not strange or unexpected.

Solution: Don't do that. Either delete the old files after archiving them, or exclude them.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Facing issues with shell script changes

My current requirement is to replace xxyxx string with value of date date1 variable holds a date and the current script writes html tags to a file as follows echo date1 nawk 'BEGIN{ FS="," print "<HTML>""<HEAD>""<p>Hi All,<br><br>There are no cases closed on the xxyxx" print ... (2 Replies)
Discussion started by: Rajesh A S
2 Replies

2. Shell Programming and Scripting

Facing issues with rsync

Hello Gurus, I am running rsync command to copy certain Directories and files into that directories to remote server. While ruuning the command all teh files has been copied but I am facing error. The below command I am executing to copy Directories and files to remote server: rsync -avrz ssh... (3 Replies)
Discussion started by: pokhraj_d
3 Replies

3. Post Here to Contact Site Administrators and Moderators

Regarding facing issues while accessing UNIX.com site

Hello Moderators/Admins, This is regarding an issue which I am facing from last 7 to 8 days. Issue is while trying to access this forum(simple hitting http://unix.com) I am able to login but many times my request gets timed out or 404 error or if I am able to login it will be excessive slow even... (0 Replies)
Discussion started by: RavinderSingh13
0 Replies

4. Shell Programming and Scripting

Facing issues with cronjobs

Hello Everyone, We have a cronjob scheduled to pick up files from one system and transfer to another system. the underlying code is a shell script. These cronjobs were working correctly until sometime. 2 days back they did not pick up the scripts but created empty logs. However when we tried... (6 Replies)
Discussion started by: Rads
6 Replies

5. UNIX for Dummies Questions & Answers

Facing issues while running a cronjob !

Hi, I am trying to run a cronjob. But while doing so I am getting the following error message :- can't open yourfile in /var/spool/cron/crontabs directory. No such file or directory How can I resolve this issue ? Please help. Thanks Please view this code tag video for... (14 Replies)
Discussion started by: acidburn_007
14 Replies

6. UNIX for Advanced & Expert Users

tar and gzip extraction issues

Not sure if this is really in the right forum but here goes.... Looking for a way to extract individual compressed files from a compressed tarball WITHOUT tar -zxvf and then recompressing. Basically we need to be able to chunk out an individual compressed file while it still remains... (6 Replies)
Discussion started by: athos
6 Replies

7. UNIX for Dummies Questions & Answers

tar and gzip

Hi, I would like to have a combined gzip and tar that will compress and create multiple output tar.gz files. I want to have multiple files output because i cannot create an archive because there is no more space on my harddisk. I cannot transfer it locally because of slow connection. I want to... (3 Replies)
Discussion started by: tungaw2004
3 Replies

8. UNIX for Advanced & Expert Users

tar/gzip/gz...which one to use?

P0251WLADC.svm_wl1 > /svm_wl1/billing/data/server/archive/ALLEVT $ du -k FEB2006 22050224 FEB2006 As you can see,i have a folder called "FEB2006" which is around 22 GB. i guess zip or compress wont work...( i don know how do we compress a folder) i wished to use ""tar" ( i suppose... (5 Replies)
Discussion started by: abhijeetkul
5 Replies

9. UNIX for Dummies Questions & Answers

TAR and GZIP help

Hi, There are 700 .pdf files in a certain directory on the server and I need to TAR them first and then compress them using GZIP to free up the space. The combined size of the .pdf files is 3gb. However, there is only 1gb of free space on the server. So as you can see when I try to TAR these... (3 Replies)
Discussion started by: VandeMatram
3 Replies

10. UNIX for Dummies Questions & Answers

can i tar and gzip in one liner ?

hello can i combine this 2 commands in one liner command? (1 Reply)
Discussion started by: umen
1 Replies
Login or Register to Ask a Question