Operating System - HP-UX
1819839 Members
2660 Online
109607 Solutions
New Discussion юеВ

Re: Copy and compress on the fly

 
SOLVED
Go to solution
Morris Makuch
Advisor

Copy and compress on the fly

Hello
I have read several of these forums responses about copy and compress files on the fly in an effort to find a solution to my problem. But I have yet to come across a clear response. Here is my issue. I have Oracle dbf files that are 8GB in size. Currently I do a hot backup of my database with the command "host cp /prod/index/index*.dbf /prod/work/backup"
The key here is that I use wildcards to specify more than 1 file. I then do a compress of the dbf files in the directory /prod/work/backup. Is there a way to do a copy and compress on the fly in 1 step using wildcards in the filename?
Thanks
6 REPLIES 6
RAC_1
Honored Contributor

Re: Copy and compress on the fly

for i in $(/prod/index/index*.dbf)
do
cp {} /dest/.
done
There is no substitute to HARDWORK
Morris Makuch
Advisor

Re: Copy and compress on the fly

What about compressing?
Steven E. Protter
Exalted Contributor

Re: Copy and compress on the fly

Manually create a list of database files to backup.

/etc/dbfback.dat


while read -r filename
do
cp $filename /backups/dbf
done < /etc/dbfback.dat

This lets you maintain the list of files as you add new databases. It can include wildcards as well.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Patrick Wallek
Honored Contributor
Solution

Re: Copy and compress on the fly

I would use a script to do it. Something like this:

cd /prod/index
for i in index*.dbf
do
compress < ${i} > /prod/work/backup/${i}.Z
done
Alzhy
Honored Contributor

Re: Copy and compress on the fly

If your dbf files are 8GB in size, then you can benefit from discovered direct-IO (and conserver cache) by using dd and at the same time compress your file on the fly:

cd /prod/index
for file in index*.dbf;do
dd if=./$file ibs=1024K | gzip > /prod/work/backup/${file}.gz
done


HTH.
Hakuna Matata.
Tim D Fulford
Honored Contributor

Re: Copy and compress on the fly

hi

# for longfile in $(ls /prod/index/index*.dbf)
> do
> file=$(basename $longfile)
> cat $longfile | gzip - > /prod/work/backup/$file.gz
>done

I would not use "compress" as it is usually less efficient than gzip & all those -c < switches get me most confused...

but I think a slightly better & more elegant way would be
# cd /prod/index
# tar cf - index*.dbf | gzip - > /prod/work/backup/backup.$(date %Y-$m-%d).tar.gz

of if you prefer fbackup (I do)
# cd /prod/index
# fbackup -f - -i index*.dbf | gzip - > /prod/work/backup/backup.$(date %Y-$m-%d).fbk.gz

The beauty of the above is to extract a single file you do not need to unzip move etc simply do the following...
# gzcat /prod/work/backup/backup.2005-04-01.fbk.gz | frecover -f - -i index12345.dbf

or to get the index of what is in the fbk file
# gzcat /prod/work/backup/backup.2005-04-01.fbk.gz | frecover -I /tmp/index -f -

You can do a similat thing with tar too.

Regards

Tim
-