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