Solved

gzip files to different directory

Posted on 2009-04-13
5
4,874 Views
Last Modified: 2013-12-27
I am running out of space to hold both my cold and hot backup of my database files.
I use three gzip scipts to zip up the database files after the cold backup - to save time.
So basically I do a find on "tool*.dbf" and gzip it - ... a find on three different file names and gzip them.
What I need to do now is to gzip them to a different directory.
gzip -c tools*.dbf >/oradata1/backup/????
I can do one file at a time if I put the name in....
gzip -c tools_01.dbf >/oradata1/backup/tools_01.dbf.gz

This won't work with multiple files.
Is there a way around this?

Thanks
0
Comment
Question by:bkreynolds48
  • 3
  • 2
5 Comments
 
LVL 22

Expert Comment

by:blu
ID: 24130145
I don't know of a way to tell gzip to write to a different output directory.

I am not sure I understand the problem totally. You say you are doing a find on file. Isn't that finding each file individually anyway?     What is the problem with runnign gzip on each individual file?
0
 
LVL 1

Author Comment

by:bkreynolds48
ID: 24130190
Blu,
This is one of my gzip scripts.........
#
cd  /backup//cold
for next_file in  $(find . -type f -print |grep -v org   )
do
/bin/gzip -f  $next_file
done
#
 
I grep or grep -v to get the files I want.
There are almost 90 database files.
Could I use $next_file like this?
gzip -f -c $next_file >oradata1/backup/$next_file.gz
Thanks
0
 
LVL 1

Author Comment

by:bkreynolds48
ID: 24130398
blu,
I created a test script using the above logic and it seems to work.
Won't know for sure until Sunday when my cold backup runs.
Thanks
0
 
LVL 22

Accepted Solution

by:
blu earned 500 total points
ID: 24130462
You could do this:

cd /backup/cold
for next_file in  $(find . -type f  ! -name \*org\* )
do
/bin/gzip -f -c $next_file > oradata1/backup/$next_file.gz
done

It is too bad that gzip doesn't have a output file flag, then you could do it all in one line.
0
 
LVL 1

Author Closing Comment

by:bkreynolds48
ID: 31569507
Once again blu I really appreciate your help.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
AIX 5.3 group password policy changes 7 29
AIX  NFS  question 1 141
Java core in Solaris 10 1 285
need to remove or skip  grub protection password in ubuntu on boot time 2 74
When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question