3.1 确认需要迁移的数据文件
查看当前的数据文件,确认将9,10,11三个文件迁移回原来的目录:
SQL> select file#, name from v$datafile; FILE# NAME ---------- ------------------------------------------------------- 1 /oradata/jy/datafile/system.256.839673875 2 /oradata/jy/datafile/undotbs1.258.839673877 3 /oradata/jy/datafile/sysaux.257.839673877 4 /oradata/jy/datafile/users.259.839673877 5 /oradata/jy/datafile/example.267.839673961 6 /oradata/jy/datafile/undotbs2.268.839674103 7 /oradata/jy/datafile/dbs_d_school.276.840618437 8 /oradata/jy/datafile/dbs_cssf_gt.289.848228741 9 /datafile/dbs_data9.dbf 10 /datafile/dbs_data10.dbf 11 /datafile/dbs_data11.dbf 11 rows selected.
3.2 备份相关数据文件副本:
编写脚本:
vi copy_datafile.sh echo "=======Begin at : `date`=======" >>/tmp/copy_datafile_`date +%Y%m%d`.log rman target / <>/tmp/copy_datafile_`date +%Y%m%d`.log run { allocate channel c1 device type disk; allocate channel c2 device type disk; allocate channel c3 device type disk; backup as copy datafile 9 format '/oradata/jy/datafile/dbs_data9.dbf'; backup as copy datafile 10 format '/oradata/jy/datafile/dbs_data10.dbf'; backup as copy datafile 11 format '/oradata/jy/datafile/dbs_data11.dbf'; release channel c1; release channel c2; release channel c3; } EOF echo "=======End at : `date`=======" >>/tmp/copy_datafile_`date +%Y%m%d`.log
后台执行脚本:nohup sh copy_datafile.sh &
记录的日志如下: