您的位置:首页 > 数据库 > Oracle

ORACLE 一个完整的rman备份脚本

2017-08-31 09:37 579 查看
#!/bin/bash

. ~/.bash_profile

export ORACLE_SID=prdrisk

DATE1=`date '+%Y%m%d'_%H%M%S`

mv /dbfile/scripts/log/*.log /dbfile/scripts/logs/.

$ORACLE_HOME/bin/rman log=/dbfile/scripts/log/Rman_prdrisk_$DATE1.log << EOF

connect target /;

crosscheck archivelog all;

run {

    allocate channel ch1 device type disk ;

    report schema;

    crosscheck backup of database;

    crosscheck backup of archivelog all;

    crosscheck backup of controlfile;

    crosscheck backup of spfile;

    crosscheck archivelog all;

    delete noprompt force expired backup;

    delete noprompt force expired archivelog until time 'sysdate-0.5';

    delete noprompt force expired copy;

    delete noprompt force obsolete;

    report need backup;

    report unrecoverable;

    release channel ch1;

}

run{

allocate channel ch1 device type disk maxpiecesize=4096M;

allocate channel ch2 device type disk maxpiecesize=4096M;

allocate channel ch3 device type disk maxpiecesize=4096M;

allocate channel ch4 device type disk maxpiecesize=4096M;

backup  as compressed backupset incremental level 0 

format '/dbfile/rmanbak/prdrisk_%p_%s_%u.ful'

(database);

sql 'alter system archive log current';

backup as compressed backupset 

 format '/dbfile/rmanbak/prdrisk_%p_%s_%u.arb'

(archivelog all);

backup

 format '/dbfile/rmanbak/prdrisk_%p_%s.ctb'

(current controlfile);

backup spfile format '/dbfile/rmanbak/%d_sp_%s_%p_%t.sbk' tag 'spfile_backup';

release channel ch1;

release channel ch2;

release channel ch3;

release channel ch4;

}

exit;

EOF
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: