Solved

gzip files to different directory

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
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…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

707 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

15 Experts available now in Live!

Get 1:1 Help Now