Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying files where destination directory does not exist 1

Status
Not open for further replies.

MCubitt

Programmer
Mar 14, 2002
1,081
GB
I am hoping there is an easy way to do this but...

I am generating a script which essentially copies files to a back up location. The source path and file is generated from a data table (Oracle) so essentially you have:

/oracledata/LIVE/temp.dbf
/redolog1/LIVE/redo01.log
/redolog1/LIVE/redo02.log

to be copied to

/backup/oracledata/LIVE/temp.dbf
/backup/redolog1/LIVE/redo01.log
/backup/redolog1/LIVE/redo02.log

so scriptB needs to be
cp /oracledata/LIVE/temp.dbf /backup/oracledata/LIVE/
cp /redolog1/LIVE/redo01.log /backup/redolog1/LIVE/redo01.log cp /redolog1/LIVE/redo02.log /backup/redolog1/LIVE/redo02.log



In order to keep things "clean" I would start the script by clearing everything from /backup (do I need to name each one or can I generically do this?)

Rather than mkdir /backup/oracledata
then mkdir /nackup/oracledata/LIVE
etc



I am not making myself very clear for which I apologise.

In a nutshell I want to take the following code:
Code:
spool &fil
select 'host cp -p '|| name ||' &dir' from v$datafile order by 1;
select 'host cp -p '|| member ||' &dir' from v$logfile order by 1;
select 'host cp -p '|| name ||' &dir' from v$controlfile order by 1;
select 'host cp -p '|| name ||' &dir' from v$tempfile order by 1;
spool off;

copy to the same path as the source with /backup (&dir) in front.

Thanks!




Applications Support
UK
 
This should do it:
Code:
rm -Rf /backup/*

pax -rw /oracledata/LIVE/temp.dbf /backup
pax -rw /redolog1/LIVE/redo01.log /backup
pax -rw /redolog1/LIVE/redo02.log /backup

Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

 
Rod,

Did I ever tell you that you are my hero?

Blooming excellent !

Thanks


Applications Support
UK
 
Aw shucks.

I must admit, mostly because I like coincidences, that I found out that pax could do that about an hour before I saw MCubitt's OP.



Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top