linux 下的 oracle 自动备份脚本
作者 佚名技术
来源 Linux系统
浏览
发布时间 2012-03-25
这个脚本比较简单:
周天对数据库进行全备,周一到周六进行归档日志备份.
[oracle@T10 ~]$ cat backup.sh #!/bin/bash #oracle backup script btime=`date %A` export ORACLE_SID=snzo export ORACLE_HOME=/u01/oracle/product/10g/db if [ $btime = "Sunday" ] ; then /u01/oracle/product/10g/db/bin/rman target / cmdfile=/home/oracle/datafile.sql log=/home/oracle`date %Y-%m-%d`_dbf.log else /u01/oracle/product/10g/db/bin/rman target / cmdfile=/home/oracle/archive.sql log=/home/oracle/`date %Y-%m-%d`_arc.log fi 备份数据库的数据库脚本: [oracle@T10 ~]$ cat datafile.sql run { allocate channel ch1 type disk; allocate channel ch2 type disk; backup database format ''/u01/oracle/backup/%U_%T.dbf''; backup archivelog all delete input format ''/u01/oracle/backup/%U_%T.arc''; release channel ch1; release channel ch2; } exit 备份归档日志的脚本: [oracle@T10 ~]$ cat archive.sql run { allocate channel ch1 type disk; backup archivelog all delete input format ''/u01/oracle/backup/%U_%T.arc''; release channel ch1; } exit 设置crontab: [oracle@T10 ~]$ crontab -l SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin:/u01/orace/product/10g/db/bin HOME=/home/oracle */5 * * * * /home/oracle/backup.sh 此处为测试,没5分钟进行一次备份. 查看备份结果: [oracle@T10 ~]$ cat 2011-10-19_arc.log Recovery Manager: Release 10.2.0.4.0 - Production on Wed Oct 19 16:55:01 2011 Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to target database: SNZO (DBID=2088621957) RMAN> run 2> { 3> allocate channel ch1 type disk; 4> backup archivelog all format ''/u01/oracle/backup/%U_%T.arc'';
5> release channel ch1; 6> } 7> exit using target database control file instead of recovery catalog allocated channel: ch1 channel ch1: sid=10 devtype=DISK Starting backup at 19-OCT-11 current log archived channel ch1: starting archive log backupset channel ch1: specifying archive log(s) in backup set input archive log thread=1 sequence=102 recid=14 stamp=764953366 input archive log thread=1 sequence=103 recid=15 stamp=764953435 input archive log thread=1 sequence=104 recid=16 stamp=764956491 input archive log thread=1 sequence=105 recid=17 stamp=764958304 input archive log thread=1 sequence=106 recid=18 stamp=764958604 input archive log thread=1 sequence=107 recid=19 stamp=764958903 input archive log thread=1 sequence=108 recid=20 stamp=764959203 input archive log thread=1 sequence=109 recid=21 stamp=764959503 input archive log thread=1 sequence=110 recid=22 stamp=764959803 input archive log thread=1 sequence=111 recid=23 stamp=764960103 channel ch1: starting piece 1 at 19-OCT-11 channel ch1: finished piece 1 at 19-OCT-11 piece handle=/u01/oracle/backup/1rmpgnb7_1_1_20111019.arc tag=TAG20111019T165503 comment=NONE channel ch1: backup set complete, elapsed time: 00:00:02 Finished backup at 19-OCT-11 Starting Control File and SPFILE Autobackup at 19-OCT-11 piec |
|
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
上一篇: 用Apache2的mod_deflate模块来压缩页面下一篇: 还是搬到csdn博客吧~
关于linux 下的 oracle 自动备份脚本的所有评论