1.编写备份脚本
通过操作系统的命令来实现的备份机制:cp、scp
1.1查询所有的文件所在位置(数据文件,控制文件,参数文件,重做日志文件,密码文件)
SYS@orcl11g> select name from v$datafile
2 union
3 select name from v$controlfile
4 union
5 select member from v$logfile;
1.2创建备份的路径
SYS@orcl11g> host mkdir /u01/app/backup
1.3通过select语句构建拷贝脚本
SYS@orcl11g> set trim on 截取掉不必要的空格
SYS@orcl11g> set trims on 每个行的空格
SYS@orcl11g> set heading off 去掉标题
SYS@orcl11g> set echo off 去掉反馈
SYS@orcl11g> set feedback off 去掉回显
SYS@orcl11g> set term off 关闭终端信息
SYS@orcl11g> spool /home/oracle/cp.sql
SYS@orcl11g>select 'cp '||name||' /u01/app/backup' from v$datafile
union
select 'cp ' ||name|| ' /u01/app/backup' from v$controlfile
union
select 'cp '||member||' /u01/app/backup' from v$logfile
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
SYS@orcl11g> select 'cp ' || name || ' /u01/app/backup/' from 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 ~]$ vi cp.sql
[oracle@db253 ~]$ cat cp.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 +x cp.sql
awk构建命令:
ls -lSr /test | awk '{print "mv " $NF" /tmp/test/t"NR".conf"}' | bash
2.停止数据库
sql> shutdown immediate;
3.拷贝数据文件
[oracle@db253 ~]$ /home/oracle/cp.sql --执行脚本
4.开启数据库
sql> startup;
创新互联服务项目包括墨脱网站建设、
墨脱网站制作、墨脱网页制作以及墨脱网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,
墨脱网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到墨脱省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
分享文章:Oracle数据库的冷备-创新互联
本文地址:
http://kswsj.cn/article/cesogg.html