溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

ORCLE RMAN備份腳本

發(fā)布時間:2020-06-28 08:44:04 來源:網(wǎng)絡(luò) 閱讀:1259 作者:luoyangzhigui 欄目:關(guān)系型數(shù)據(jù)庫

1、Linux下oracle備份腳本

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1

export PATH=$PATH:$ORACLE_HOME/bin:

export NLS_LANG=AMERICAN_AMERICA.zhs16gbk

export ORACLE_SID=orcl

rman target / nocatalog log=/tmp/rman_full.log append<<EOF

run{

allocate channel c1 type disk;

allocate channel c2 type disk;

backup filesperset 3 database format '/oracle/backup/full_%d_%T_%s_%p';

sql 'alter system archive log current';

sql 'alter system archive log current';

sql 'alter system archive log current';

backup archivelog all format '/oracle/backup/arch_%d_%T_%s_%p' delete input;

backup current controlfile format '/oracle/backup/ctl_%d_%T_%s_%p';

}

EOF


Linux下刪除過期備份的腳本

rman target / nocatalog log=/tmp/rman_delete.log append<<EOF

run{

allocate channel for maintenance type disk;

crosscheck backup;

crosscheck archivelog all;

delete noprompt archivelog until time 'sysdate-1';

delete noprompt obsolete;

}

EOF


注:將腳本添加到crontab中定時執(zhí)行即可。


2、windows下ORACLE備份腳本

全庫備份腳本full_backup.txt

run{

allocate channel c1 type disk;

allocate channel c2 type disk;

backup filesperset 2 database format 'd:\u01\rman\full_%d_%T_%s_%p';

sql 'alter system archive log current';

sql 'alter system archive log current';

sql 'alter system archive log current';

backup archivelog all format 'd:\u01\rman\arch_%d_%T_%s_%p' delete input;

backup current controlfile format 'd:\u01\rman\ctl_%d_%T_%s_%p';

backup spfile format 'd:\u01\rman\spfile_%d_%T_%s_%p';

}

exit


全庫備份可執(zhí)行腳本full_backup.bat

rman target / nocatalog log=d:\u01\rman.log append CMDFILE 'd:\u01\full_backup.txt';


歸檔日志備份腳本log_backup.txt

run{

backup archivelog all format 'd:\u01\rman\arch_%d_%T_%s_%p' delete input;

}

exit


刪除過期備份腳本delete_obsolete.txt

run{

crosscheck backup;

crosscheck archivelog all;

delete noprompt archivelog until time 'sysdate-1';

delete noprompt obsolete; 

}

exit


注:windows下備份需要添加定時任務(wù)

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI