配置rman
登入rman
rman target /
rman> show all
2> ;
using target database control file instead of recovery catalog
rman configuration parameters for database with db_unique_name pu are:
configure retention policy to recovery window of 7 days; ----備份過期設定到7天
configure backup optimization off; # default
configure default device type to disk; # default
configure controlfile autobackup off; -----不開啟,自己寫備份指令碼
configure controlfile autobackup format for device type disk to '/u01/rmanbackup/bak_%f'; -----備份存放的路徑
configure device type disk parallelism 1 backup type to backupset; # default
configure datafile backup copies for device type disk to 1; # default
configure archivelog backup copies for device type disk to 1; # default
configure maxsetsize to unlimited; # default
configure encryption for database off; # default
configure encryption algorithm 'aes128'; # default
configure compression algorithm 'basic' as of release 'default' optimize for load true ; # default
configure archivelog deletion policy to none; # default
configure snapshot controlfile name to '/u01/11g/dbs/snapcf_pu.f'; # default
編寫level0指令碼
#!/bin/bash
#export nls_lang='american_america.al32utf8' ----字符集設定
export oracle_base=/u01/oracle----目錄
export oracle_home=/u01/11g----家目錄
export oracle_sid=pu----sid
#export path=$path:$oracle_home/bin----絕對路徑下,加這行
/u01/11g/bin/rman target / <-----開啟兩個佇列
backup incremental level 0 format '/u01/rmanbackup/lev0_db_%d_%t_t%t_s%s_p%p' database;-----備份資料庫
sql 'alter system archive log current';-----切換當前日誌
backup format '/u01/rmanbackup/lev0_controlfile_%d_%t_t%t_s%s_p%p' current controlfile;-----備份當前歸檔日誌
backup archivelog all delete input format '/u01/rmanbackup/lev0_log_%d_%t_t%t_s%s_p%p';-----備份歸檔日誌,並清空已備份的歸檔日誌
release channel c1;
release channel c2;
crosscheck backup;-----檢查過期的備份
delete noprompt obsolete;-----刪除過期的備份
}exit;
<
編寫level1指令碼
#!/bin/bash
#export nls_lang='american_america.al32utf8' ----字符集設定
export oracle_base=/u01/oracle----目錄
export oracle_home=/u01/11g----家目錄
export oracle_sid=pu----sid
#export path=$path:$oracle_home/bin----絕對路徑下,加這行
/u01/11g/bin/rman target / <-----開啟兩個佇列
backup incremental level 0 format '/u01/rmanbackup/lev1_db_%d_%t_t%t_s%s_p%p' database;-----備份資料庫
sql 'alter system archive log current';-----切換當前日誌
backup format '/u01/rmanbackup/lev1_controlfile_%d_%t_t%t_s%s_p%p' current controlfile;-----備份當前歸檔日誌
backup archivelog all delete input format '/u01/rmanbackup/lev1_log_%d_%t_t%t_s%s_p%p';-----備份歸檔日誌,並清空已備份的歸檔日誌
release channel c1;
release channel c2;
crosscheck backup;-----檢查過期的備份
delete noprompt obsolete;-----刪除過期的備份
}exit;
《寫入到crontab裡面
[oracle@oracle ~]$ crontab -l
#2 level0
0 0 * * 2 /home/oracle/level_0.sh >>/tmp/bak.log 2>&1 每週2,0點0分做0級備份,備份日誌儲存到/tmp/bak.log
#level1
0 0 * * 0,1,3,4,5,6 /home/oracle/level_1.sh 1級備份
rman備份方法之 增量備份
使用型別 系統負載集中在某那個時間段,如白天8小時,晚上基本很閒,所以在晚上就可以對資料進行備份 與之相對應的是全庫備份 1 env ip 10.244.171.180 181 oracle database oracle 11.2.0.3 os rhel 5.5 backup toos rman,...
rman備份指令碼
more backup full xxb.sh database rman backup full run echo begin time date y m d date h m s rq1 date y m d date h m s rman target cmdfile backup run f...
RMAN常用備份指令碼
1.基本0的增量備份 create script.b whole inc0 2.基本1的增量備份 create script.b whole inc1 3.基本2的增量備份 create script.b whole inc2 4.歸檔當前的重做日誌組 create script.archive l...