Operating System - Linux
1756952 Members
2460 Online
108857 Solutions
New Discussion юеВ

Re: Single cmdline shell for copying all dbf's, ctl file recursively from one system to another.

 
Srikanth Arunachalam
Trusted Contributor

Single cmdline shell for copying all dbf's, ctl file recursively from one system to another.

Hi,

I have 2 system with same filesystem structure. I need to clone my database that I want to copy all the dbf, ctl files from one system to another. I am not supposed to make use of rcp.

I tried using scp -r find /u01/oradata/omc/srs_1 -name "*.dbf" oracle@system2:${PWD}
from system2.

Althogh it tried copying files across it created a new directory under /u01/oradata/omc/omc/srs_1/srs_1/ and then copied all the files.

I dont want to rely on this command. Please give me any other command that does a clean copying of all dbf files within another system.

For example on system1, I have
/u01/oradata/omc/srs_1/srs_1_a.dbf
/u01/oradata/omc/srs_2/srs_1_a.dbf
/u01/oradata/omc/ctl/ctl01.ctl

I want to copy all of these files to system2 which has same file structure and on the same area.

Thanks,
Srikanth A
8 REPLIES 8
Peter Godron
Honored Contributor

Re: Single cmdline shell for copying all dbf's, ctl file recursively from one system to another.

Hi,
you could combine find and tar to backup your files with absolute pathnames and copy the tar file. Beware of the normal 2Gb limit.
That way once you tar -x on the target machine the files are written to their proper locations.
Yang Qin_1
Honored Contributor

Re: Single cmdline shell for copying all dbf's, ctl file recursively from one system to another.

Or, if you want to use ${PWD} you have to cd to /u01/oradata/omc then run scp command. Otherwise, use absolute path instead of ${PWD}.


Yang
Jean-Yves Picard
Trusted Contributor

Re: Single cmdline shell for copying all dbf's, ctl file recursively from one system to another.

hello,

from system 1 under ksh or bash

scp $(find /u01/oradata/omc \( -name "*.dbf" -o -name "*.ctl" \) -print ) oracle@system2:/

Jean-Yves
Srikanth Arunachalam
Trusted Contributor

Re: Single cmdline shell for copying all dbf's, ctl file recursively from one system to another.

Hi,

The scp command doesnt work. It is trying to copy everything in the root directory!!!.

Thanks,
Srikanth A
Jean-Yves Picard
Trusted Contributor

Re: Single cmdline shell for copying all dbf's, ctl file recursively from one system to another.

hello,

second try :
scp $(find /u01/oradata/omc \( -name "*.dbf" -o -name "*.ctl" \) -print ) oracle@system2:/u01/oradata/omc

Jean-Yves Picard
PAVIC Thierry
Frequent Advisor

Re: Single cmdline shell for copying all dbf's, ctl file recursively from one system to another.

if you database is in archive log mode, you can copy it without close it

first put it 'begin backup mode'
copy all file :dbf, redo, make your new ctl file
and copy the archivelog file since the begin of copy

flag_arch=/tmp/Arch_${NEW_ORACLE_SID}
rm -f ${flag_arch}
touch ${flag_arch}

find ${ACTUAL_DIR} -type f -newer ${flag_arch} -exec scp {} ${NEW_SERVER}:${NEW_DIR} \
;

make a recover

and make end backup.
Yogeeraj_1
Honored Contributor

Re: Single cmdline shell for copying all dbf's, ctl file recursively from one system to another.

hi Srikanth,

the ideal method would be to use the Duplicate option in RMAN.

If you have metalink access, please refer to note: 388431.1 - "Creating a Duplicate Database on a New Host".

The steps listed in the note are:
1. Backup the primary database.

2. Determine how much disk space will be required.

3. Ensuring you have enough space on your target server.

4. Making the backup available for the duplicate process.

5. Creating the init.ora & administration directories for the duplicate database.

6. Ensuring SQL*NET connections to primary database and RMAN catalog are working.

7. Prepare RMAN duplicate script.

8. Execute the RMAN script.


hope this helps too!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Steve Post
Trusted Contributor

Re: Single cmdline shell for copying all dbf's, ctl file recursively from one system to another.

believe it or not, I don't like tar. I like cpio.
-----------------------------
Copy boxA:/dir1/A to boxA:/dir342/A.

On box A
cd /dir1
find A -print | cpio -pdumvc /dir342/.

---------------------------------
Copy boxA:/dir1/A to BOXB:/dir342/A.
On BOXB
make sure directory /dir342 exists and has the correct permissions.

On box A
cd /dir1
find A -print | cpio -odumvc | /usr/bin/ssh user@BOXB \
"cd /dir342;/usr/bin/cpio -idumvc"

man find
man cpio
man ssh

steve