oracle rman 备份数据库常用脚本详解数据库

$ vi vi bk_db_full.sh

ORACLE_BASE=/u01/app/oracle

ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1

ORACLE_SID=orcl

NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

PATH=$PATH:/ORACLE_HOME/bin

ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data

PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$ORACLE_HOME/opatch

CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

CLASSPATH=$CLASSPATH:$ORACLE_HOME/network/jlib

export ORA_NLS33

export ORACLE_BASE ORACLE_HOME ORACLE_SID 

export DB_NAME NLS_LANG PATH LD_LIBRARY_PATH CLASSPATH DB_NAME 

rman target=/ cmdfile=/u03/rman/rman_script/bk_db_full.rman log=/u03/rman/rman_log/bk_db_full_`date +%Y%m%d%H%M%S`.log

$ vi bk_db_full.rman

run
{
        ALLOCATE CHANNEL CH1 DEVICE TYPE DISK MAXPIECESIZE=20000M ; 
        sql ‘ALTER SYSTEM CHECKPOINT’;
        backup as compressed backupset incremental level 0 cumulative database include current controlfile 
        format ‘/mnt/backup/DB_%d_%U_%T.BKP’;  
        RELEASE CHANNEL CH1; 
}

run
{       
        ALLOCATE CHANNEL CH1 DEVICE TYPE DISK MAXPIECESIZE=8000M ; 
        sql ‘ALTER SYSTEM CHECKPOINT’;
        sql ‘ALTER SYSTEM ARCHIVE LOG CURRENT’;
        sql ‘ALTER SYSTEM ARCHIVE LOG CURRENT’;
        backup as compressed backupset archivelog all delete input 
        format ‘/mnt/backup/ARCH_%d_%U_%T.BKP’;
        RELEASE CHANNEL CH1;
}

run
{
        ALLOCATE CHANNEL CH1 DEVICE TYPE DISK MAXPIECESIZE=8000M;
        backup current controlfile format ‘/mnt/backup/CTL_%d_%U_%T.BKP’;
        RELEASE CHANNEL CH1;
}

crosscheck backup;
crosscheck archivelog all;
delete noprompt expired backup;
delete expired archivelog all;
delete force noprompt obsolete recovery window of 15 days;

list backup;
exit;

原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/3914.html

(0)
上一篇 2021年7月16日
下一篇 2021年7月16日

相关推荐

发表回复

登录后才能评论