启动2个终端
步骤1:
终端1: mkdir /home/oracle/data
步骤2:
新建back.sql文件写入下面内容
终端1:
spool /home/oracle/temp.sql
select 'ho cp '||name||' /home/oracle/data/' from v$controlfile
union all
select 'ho cp '||name||' /home/oracle/data/' from v$datafile
union all
select 'ho cp '||name||' /home/oracle/data/' from v$tempfile
union all
select 'ho cp '||member||' /home/oracle/data/' from v$logfile
/
create pfile='/home/oracle/data/initorcl.ora' from spfile;
ho cp $ORACLE_HOME/dbs/orapworcl /home/oracle/data/
spool off
ho sed -n '/^ho cp/p' /home/oracle/temp.sql>/home/oracle/backup.sql
shutdown
@/home/oracle/backup.sql
步骤3:
终端2:
在open状态下的oracle中执行@/home/oracle/back.sql
执行完之后会生成/home/oracle/backup.sql文件。
步骤4:
终端2:
在oracle关闭的状态下执行@/home/oracle/backup.sql