一周RMAN备份脚本
Posted datalife
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一周RMAN备份脚本相关的知识,希望对你有一定的参考价值。
#! /bin/bash
#crontab---->00 20 * * 0 su - oracle -c ‘/scripts/oracle_full_backup.sh‘
#crontab---->00 20 * * 1-6 su - oracle -c ‘/scripts/oracle_inc_backup.sh‘
export BACKUP_DIR=/backup
export ORACLE_HOME=/oracle/oracle/product/11.2.0/db_1
#exec >> delarch`date +%y%m%d%H`.log
exec > /backup/rman_orcldb_backup.log
###############################################
$ORACLE_HOME/bin/rman target / <<EOF
########################start script_rman_full.sh #################################
#backup database level=0
run {
ALLOCATE CHANNEL ch00 DEVICE TYPE DISK ;
ALLOCATE CHANNEL ch01 DEVICE TYPE DISK ;
backup as compressed backupset incremental level = 0 database format ‘$BACKUP_DIR/%d_%T_dbfull_%t_%s_%p‘;
sql ‘alter system archive log current‘;
release CHANNEL ch00;
release CHANNEL ch01;
}
#backup archivelog
run{
ALLOCATE CHANNEL ch00 DEVICE TYPE DISK CONNECT ‘sys/[email protected]‘;
ALLOCATE CHANNEL ch01 DEVICE TYPE DISK CONNECT ‘sys/[email protected]‘;
backup archivelog all format ‘$BACKUP_DIR/%d_%T_arch_%t_%s_%p‘ delete all input;
release CHANNEL ch00;
release CHANNEL ch01;
}
#backup controlfile
run{
ALLOCATE CHANNEL ch00 DEVICE TYPE DISK ;
ALLOCATE CHANNEL ch01 DEVICE TYPE DISK ;
backup current controlfile format ‘$BACKUP_DIR/%d_%T_ctl_%t_%s_%p‘;
release CHANNEL ch00;
release CHANNEL ch01;
}
delete noprompt obsolete recovery window of 30 days;
##########################end script_rman_full.sh #################################
exit;
EOF
echo ‘===THE FULL BACKUP OF END TIME IS ‘$(date +%Y/%m/%d/%H:%M:%S)===
#! /bin/bash
#crontab---->00 20 * * 0 su - oracle -c ‘/scripts/oracle_full_backup.sh‘
#crontab---->00 20 * * 1-6 su - oracle -c ‘/scripts/oracle_inc_backup.sh‘
export BACKUP_DIR=/backup
export ORACLE_HOME=/oracle/oracle/product/11.2.0/db_1
#exec >> delarch`date +%y%m%d%H`.log
exec > /backup/rman_orcldb_backup.log
###############################################
$ORACLE_HOME/bin/rman target / <<EOF
########################start script_rman_full.sh #################################
#backup database level=1
run {
ALLOCATE CHANNEL ch00 DEVICE TYPE DISK ;
ALLOCATE CHANNEL ch01 DEVICE TYPE DISK ;
backup as compressed backupset incremental level = 1 cumulative database format ‘$BACKUP_DIR/%d_%T_dbinc_%t_%s_%p‘;
sql ‘alter system archive log current‘;
release CHANNEL ch00;
release CHANNEL ch01;
}
#backup archivelog
run{
ALLOCATE CHANNEL ch00 DEVICE TYPE DISK CONNECT ‘sys/[email protected]‘;
ALLOCATE CHANNEL ch01 DEVICE TYPE DISK CONNECT ‘sys/[email protected]‘;
backup archivelog all format ‘$BACKUP_DIR/%d_%T_arch_%t_%s_%p‘ delete all input;
release CHANNEL ch00;
release CHANNEL ch01;
}
#backup controlfile
run{
ALLOCATE CHANNEL ch00 DEVICE TYPE DISK ;
ALLOCATE CHANNEL ch01 DEVICE TYPE DISK ;
backup current controlfile format ‘$BACKUP_DIR/%d_%T_ctl_%t_%s_%p‘;
release CHANNEL ch00;
release CHANNEL ch01;
}
##########################end script_rman_full.sh #################################
exit;
EOF
echo ‘THE INC BACKUP OF END TIME IS ‘$(date +%Y/%m/%d/%H:%M:%S)
以上是关于一周RMAN备份脚本的主要内容,如果未能解决你的问题,请参考以下文章
利用SHELL脚本来验证Oracle数据库RMAN备份集的有效性