ITPub博客

首页 > Linux操作系统 > Linux操作系统 > rman 备份

rman 备份

原创 Linux操作系统 作者:ttboylb 时间:2011-07-14 10:13:51 0 删除 编辑

rman 备份

---------------------------------------------------------------------------
CONTROL file 保留参数设置:
SQL>alter system set control_file_record_keep_time=14 scope=both;   归档路径设置
SQL〉alter system set  log_archive_dest_1='location=/arch' scope=spfile; 数据库必须启用在 archive log 状态
SQL> shutdown immediate
SQL> startup mount
SQL> alter database archivelog;
SQL> alter system archive log start;
SQL> alter database open;
/oracle/rmanscript/rman_full.sh
----------------------------------------------------------------------------
rman target / nocatalog msglog /oracle/rmanscript/rman_full.log append << EOF
run
{
allocate channel c1 type disk maxpiecesize 20G;
backup format '/orabak/billing/full_%s_%p_%t' database;
backup current controlfile format '/orabak/billing/control_%s_%p_%t';
release channel c1;
}
exit;
/oracle/rmanscript/rman_arch.sh
-----------------------------------------------------------------------------
rman target / nocatalog msglog /oracle/rmanscript/rman_arch.log append << EOF
run
{
allocate channel c1 type disk;
sql 'alter system archive log current';
backup format '/orabak/billing/arch_%s_%p_%t' archivelog all delete input;
release channel c1;
}
exit;
/oracle/rmanscript/rman_check.sh
-----------------------------------------------------------------------------
find /orabak/billing -name 'arch*' -mtime +14 -exec rm {} \;
find /orabak/billing -name 'full*' -mtime +14 -exec rm {} \;
find /orabak/settle -name 'control*' -mtime +14 -exec rm {} \;
rman target / nocatalog msglog /oracle/rmanscript/rman_check.log append << EOF
crosscheck backupset;
delete noprompt expired backupset;
exit;
新建 orabak 用户 属组 为 dba,其crontab 如下设置:
------------------------------------------------------------------------------
20 3 * * 0 /oracle/rmanscript/rman_full.sh
0 5 * * * /oracle/rmanscript/rman_arch.sh
0 6 * * * /oracle/rmanscript/rman_check.sh   ------------------------------------------------------------------------------ /oracle/rmanscript/rman_full.sh
----------------------------------------------------------------------------
rman target / nocatalog msglog /oracle/rmanscript/rman_full.log << EOF
run
{
allocate channel c1 type disk maxpiecesize 20G;
backup format '/orabak/settle/full_%s_%p_%t' database;
backup current controlfile format '/orabak/settle/control_%s_%p_%t';
release channel c1;
}
exit;
/oracle/rmanscript/rman_arch.sh
---------------------------------------------------------------------
rman target / nocatalog msglog /oracle/rmanscript/rman_arch.log << EOF
run
{
allocate channel c1 type disk;
sql 'alter system archive log current';
backup format '/orabak/settle/arch_%s_%p_%t' archivelog all delete input;
release channel c1;
}
exit;
/oracle/rmanscript/rman_check.sh
------------------------------------------------------------------------
find /orabak/settle -name 'arch*' -mtime +14 -exec rm {} \;
find /orabak/settle -name 'full*' -mtime +14 -exec rm {} \;
find /orabak/settle -name 'control*' -mtime +14 -exec rm {} \;
rman target / nocatalog msglog /oracle/rmanscript/rman_check.log << EOF
crosscheck backupset;
delete noprompt  expired backupset;
exit;
新建 orabak 用户 属组 为 dba,其crontab 如下设置:
-------------------------------------------------------------------------
0 0 * * 0 . /home/oracle/.bash_profile; /oracle/rmanscript/rman_full.sh
0 2 * * * . /home/oracle/.bash_profile; /oracle/rmanscript/rman_arch.sh
0 3 * * * . /home/oracle/.bash_profile; /oracle/rmanscript/rman_check.sh

 

 

 

 

export  ORACLE_BASE=/u01/app/oracle
export  ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export  ORACLE_SID=orcl
export  PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin

############################################################################################################################

rman target / nocatalog msglog /data/flash_recovery_area/backup.log append <RUN {
crosscheck backupset;
delete noprompt expired backupset;
ALLOCATE CHANNEL ch00 TYPE DISK;
BACKUP
    full
    FORMAT '/data/flash_recovery_area/bk_%s_%p_%d_%T.bk'
    DATABASE;
    sql 'alter system archive log current';
RELEASE CHANNEL ch00;
}
EOF

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12131609/viewspace-702157/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-01-07

  • 博文量
    60
  • 访问量
    251846