Tar.gz help - Need to tweak

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Tar.gz help - Need to tweak
# 1  
Old 04-04-2017
Tar.gz help - Need to tweak

Hi Guys -

I need help tweaking my tar.gz process. Currently, I compress all files in a directory, in which the parent directory is included in that.

I only want to compress the "*.txt" files in the follow process:

Code:
tar -zcvf ${_ESSB_TAR_PATH}/Essbase_Exports_${_DATETIMESTAMP}.tar.gz -C / u01/app/Hyperion_Batch/Exports/Essbasez
RVAL=$?

if [ $RVAL -eq 0 ]
then
  echo ---------------------------------------------------------
  echo "Zip Essbase Export Files : Successful"                           
  echo ---------------------------------------------------------
  
else
  echo ---------------------------------------------------------
  echo "Zip Essbase Export Files : Unsuccessful"                      
  echo ---------------------------------------------------------
  exit 1
  fi

I've used the find feature of and piped results to tar but then I get the silly "tar: Removing leading `/' from member names" srderror, hence why I'm doing -C / above.

Can anyone help me? The reason for this is I want to put the tar.gz file in the same directory as the files I'm compressing. If I tried to place the results int he same directory using the code above, it would give me an error saying it was still modifying the directory and what not.

Thank you!
# 2  
Old 04-04-2017
Is this just a case of appending *.txt to the long pathname you already have, or have i missed the point?
Code:
tar -zcvf ${_ESSB_TAR_PATH}/Essbase_Exports_${_DATETIMESTAMP}.tar.gz -C / u01/app/Hyperion_Batch/Exports/Essbasez/*.txt

Are there very many files that causes this to about (command line too long) or something else?

If I've misunderstood, can you illustrate what I'm not understanding.

An alternate might be to:-
Code:
pushd /u01/app/Hyperion_Batch/Exports/Essbasez      # Change directory but remember history
tar -zcvf ${_ESSB_TAR_PATH}/Essbase_Exports_${_DATETIMESTAMP}.tar.gz *.txt
RVAL=$?
popd                                                # Put you back to where you were.

if ....... #and the rest of your script.




Thanks,
Robin

Last edited by rbatte1; 04-04-2017 at 06:08 AM.. Reason: Added pushd/popd options
This User Gave Thanks to rbatte1 For This Post:
# 3  
Old 04-04-2017
Hi Robin -

Your alternative solution works great! Thank you so much! I use PUSH and POPD quite a bit in batch.

Thanks again and have a great day!
# 4  
Old 04-04-2017
What's so silly about the message cited? It's NOT an error, it's for your safety when restoring so files will not be overwritten, but there's other means to achieve this, e.g. ..skip-old-files. Or:

man tar:
Quote:
-P, --absolute-names
don't strip leading '/'s from file names
Also, the second "error" you quote is more an info. It's always worthwhile to read, analyse, and understand those messages. "What not" doesn't seem to be the result of such.
Try to --exclude the target archive - if it IS due to rhat file. Are you sure it's not the database files that are modified / written to during archiving? It's not a good idea to do a system archive with a DB live, as on restore the DB may be in an inconsistent state. Use DB tools to archive.

Last edited by RudiC; 04-04-2017 at 06:33 AM..
This User Gave Thanks to RudiC For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl find command tweak

i use the following command to find files that were recently updated within the last hour: perl -MFile::Find -le' find { wanted => sub { -f and 3600 / 86400 >= -M and print $File::Find::name; } }, shift' /var/app/mydata/ this command works well. however, it seems to also search directories... (1 Reply)
Discussion started by: SkySmart
1 Replies

2. Shell Programming and Scripting

perl line needing a tweak

Hi Folks, I have a perl line that looks like this and it works fine as is, but I need it to expand a bid further. perl -aF, -ne 'printf "conf zone %2\$s delete host %s,,,$F\n",split/\./,$F,2 if /^hostrecord/ &&/\b10\.8\.(|1)\.\d/' hosts.csv this code the way it is does this 10.8.3.0... (10 Replies)
Discussion started by: richsark
10 Replies

3. Shell Programming and Scripting

SED script needs tweak

I have a SED script that has worked for years, but broke today due to a new variable in a remote file. This is the part of the script that now won't work: sed "s|/directory/overview.gif|/directory/img/overview2.gif|g" | \ The path /directory/overview.gif is no longer static as it had been... (2 Replies)
Discussion started by: dockline
2 Replies

4. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

5. UNIX for Dummies Questions & Answers

tar -cvf test.tar `find . -mtime -1 -type f` only tar 1 file

Hi all, 4 files are returned when i issue 'find . -mtime -1 -type f -ls'. ./ora_475244.aud ./ora_671958.aud ./ora_934052.aud ./ora_934050.aud However, when I issued the below command: tar -cvf test.tar `find . -mtime -1 -type f`, the tar file only contains the 1st file -... (2 Replies)
Discussion started by: ahSher
2 Replies

6. Shell Programming and Scripting

How to tweak up

I have a script like this: while read abbrev; do sed 's/'$(echo "$abbrev" | tr "" "")'/'"$abbrev"'/g' 'output_rgt.'$$ >'tmp.'$$ mv 'tmp.'$$ 'output_rgt.'$$ done<'dict.shortcuts.'$$ And I don't know how to leave "mv" out. ('dict.shortcuts.'$$ may be... (14 Replies)
Discussion started by: MartyIX
14 Replies
Login or Register to Ask a Question