oracle数据库的冷备
前端之家收集整理的这篇文章主要介绍了
oracle数据库的冷备,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
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
每个行的空格
echo
去掉反馈
SYS@orcl11g>spool/home/oracle/cp.
sql
@H_
404_115@
select
'cp'
||
name
||
'/u01/app/backup'
v$datafile
union
v$controlfile
union
@H_
502_144@||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~]$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
[oracle@db253~]$/home/oracle/cp.
sql
原文链接:https://www.f2er.com/oracle/209140.html