您好,登錄后才能下訂單哦!
RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 14 DAYS;
啟用控制文件自動備份及備份存放位置配置
RMAN> configure controlfile autobackup on;
查看配置信息
RMAN> show all;
-------------------------------------------------
--創建文件夾
$mkdir /home/oracle/backup
mkdir /home/oracle/backup/script
mkdir /home/oracle/backup/log
mkdir /home/oracle/backup/export
--備份目的地
mkdir /home/oracle/rman_backup
創建備份表空間
create tablespace rman_tbs datafile '/u01/app/oracle/oradata/orcl11g/rman_tbs01.dbf'
size 1024M autoextend on next 50M maxsize 10240M
extent management local segment space management auto;
創建備份用戶
create user rman identified by rman default tablespace rman_tbs temporary tablespace temp;
grant connect,resource ,recovery_catalog_owner to rman;
SQL> grant unlimited tablespace to rman;
SQL> grant sysdba to rman;
rman catalog rman/rman
create catalog tablespace rman_tbs;
connect target sys/Oracle123@orcl11g
register database;
report schema;
-------------------------------------------------------
--倒出RMAN用戶數據腳本exp_rman.par (即備份catalog庫)
userid=rman/rman
file=/home/oracle/backup/export/rman.dmp
log=/home/oracle/backup/log/rman.log
-- 倒出RMAN數據SHELL腳本exp_rman.sh
#!/bin/bash
cd $HOME
. .bash_profile
cd $HOME/backup/script
exp parfile=exp_rman.par
--------------
---零級備份RMAN腳本level0_backup.rcv
connect catalog rman/rman
connect target sys/Oracle123@orcl11g
run {
allocate channel d1 type disk;
allocate channel d2 type disk;
backup incremental level 0 database format '/home/oracle/rman_backup/level0_%d_%s_%p_%u.bak'
tag='level 0' include current controlfile;
sql 'alter system archive log current';
backup archivelog all format '/home/oracle/rman_backup/arc_%d_%s_%p_%u.bak' ;
release channel d2;
release channel d1;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
crosscheck archivelog all;
delete noprompt archivelog all completed before 'sysdate-15';
resync catalog;
--零級備份SHELL腳本的level0_backup.sh
#!/bin/bash
backtime=`date +"%y%m%d%H"`
#cd $HOME
. /home/oracle/.bash_profile
cd $HOME/backup/script
rman cmdfile=level0_backup.rcv msglog=$HOME/backup/log/level0_${backtime}.log
. /home/oracle/backup/script/exp_rman.sh
一級差異增量備份RMAN腳本 level1_backup.rcv
connect catalog rman/rman
connect target sys/Oracle123@orcl11g
run {
allocate channel d1 type disk;
backup incremental level 1 format '/home/oracle/rman_backup/level1_%d_%s_%p_%u.bak' tag = 'level 1'cumulative database;
sql 'alter system archive log current';
backup archivelog all format '/home/oracle/rman_backup/log_%d_%s_%p_%u.bak' ;
release channel d1;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
crosscheck archivelog all;
delete noprompt archivelog all completed before 'sysdate-15';
resync catalog;
--一級差異增量備份SHELL腳本level1_backup.sh
#!/bin/bash
backtime=`date +"%y%m%d%H"`
#cd $HOME
. /home/oracle/.bash_profile
cd /home/oracle/backup/script
rman cmdfile=level1_backup.rcv msglog=$HOME/backup/log/level1_${backtime}.log
. /home/oracle/backup/script/exp_rman.sh
linux下定時執行備份腳本
crontab -e -u oracle
SHELL=/bin/bash --以下腳本在bash下執行
MAILTO=oracle --執行日志以郵件形式郵給oracle用戶,可以/var/spool/mail/oracle下查收
5 12 * * 1 nohup /home/oracle/backup/script/level0_backup.sh >/home/oracle/backup/cron.log 2>&1 &
5 12 * * 3 /home/oracle/backup/script/level1_backup.sh
5 12 * * 5 /home/oracle/backup/script/level1_backup.sh
一周差異備份策略:
備份目標庫和catalog庫
周一0級全備,周三周五為1級。
每天12點5分開始備份
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。