1.编写备份脚本
通过操作系统的命令来实现的备份机制:cp、scp
SYS@orcl11g>
select
name
from
v$datafile
2
union
3
v$controlfile
4
union
5
select
member
v$logfile;
1.2创建备份的路径
SYS@orcl11g>hostmkdir/u01/app/backup
1.3通过
语句构建拷贝脚本
trims
每个行的空格
heading
off
去掉标题
echo
去掉反馈
Feedback
去掉回显
term
关闭终端信息
SYS@orcl11g>spool/home/oracle/cp.sql
select
'cp'
||
name
||
'/u01/app/backup'
v$datafile
union
v$controlfile
union
||member||
v$logfile
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'/u01/app/backup/'
v$datafile;
--只备份数据文件
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
cp/u01/app/oracle/fast_recovery_area/orcl11g/control02.ctl/home/backup
cp/u01/app/oracle/oradata/orcl11g/control01.ctl/home/backup
cp/u01/app/oracle/oradata/orcl11g/example01.dbf/home/backup
cp/u01/app/oracle/oradata/orcl11g/redo01.log/home/backup
cp/u01/app/oracle/oradata/orcl11g/redo02.log/home/backup
cp/u01/app/oracle/oradata/orcl11g/redo03.log/home/backup
cp/u01/app/oracle/oradata/orcl11g/sysaux01.dbf/home/backup
cp/u01/app/oracle/oradata/orcl11g/system01.dbf/home/backup
cp/u01/app/oracle/oradata/orcl11g/undotbs01.dbf/home/backup
cp/u01/app/oracle/oradata/orcl11g/users01.dbf/home/backup
[oracle@db253~]$spool
off
[oracle@db253~]$vicp.sql
[oracle@db253~]$catcp.sql
cp/u01/app/oracle/fast_recovery_area/orcl11g/control02.ctl/home/backup
cp/u01/app/oracle/oradata/orcl11g/control01.ctl/home/backup
cp/u01/app/oracle/oradata/orcl11g/example01.dbf/home/backup
cp/u01/app/oracle/oradata/orcl11g/redo01.log/home/backup
cp/u01/app/oracle/oradata/orcl11g/redo02.log/home/backup
cp/u01/app/oracle/oradata/orcl11g/redo03.log/home/backup
cp/u01/app/oracle/oradata/orcl11g/sysaux01.dbf/home/backup
cp/u01/app/oracle/oradata/orcl11g/system01.dbf/home/backup
cp/u01/app/oracle/oradata/orcl11g/undotbs01.dbf/home/backup
cp/u01/app/oracle/oradata/orcl11g/users01.dbf/home/backup
[oracle@db253~]$chmod+xcp.sql
awk构建命令:
ls-lSr/test|awk
'{print"mv"$NF"/tmp/test/t"NR".conf"}'
|bash
2.停止数据库
sql>shutdownimmediate;
3.拷贝数据文件
[oracle@db253~]$/home/oracle/cp.sql
--执行脚本
4.开启数据库
sql>startup;
原文链接:https://www.f2er.com/oracle/209140.html