Solved

gzip files to different directory

Posted on 2009-04-13
5
4,633 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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.

896 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now