分享Oracle Rman的備份指令碼

flybluey發表於2019-09-21

#########################################################################

# File Name: backup.sh

# Created Time:XXXXX

# This is rman auto full backup script 

#########################################################################

#!/bin/bash


export ORACLE_SID=XXXX

export ORACLE_BASE=/oracle

export ORACLE_HOME=/oracle/11.2.0.4/db_1

export PATH=$ORACLE_HOME/bin:$PATH


rman target / nocatalog log=/rmanbak/XXXX/rman.log append<<EOF


run{

allocate channel c1 device type disk;

allocate channel c2 device type disk;


crosscheck backup;

sql 'alter system archive log current';

backup as compressed backupset database format '/rmanbak/XXXX/db_%d_%T_%s_%p.bak';

sql 'alter system archive log current';

backup archivelog all format '/rmanbak/XXXX/arch_%d_%T_%s_%p.bak';

backup current controlfile format '/rmanbak/XXXX/ctl%d_%T_%s.bak';


delete noprompt obsolete;

crosscheck archivelog all;

delete noprompt expired archivelog all;

crosscheck backup;

delete noprompt expired backup;

DELETE noprompt ARCHIVELOG FROM TIME 'SYSDATE-3';

release channel c1;

release channel c2;

}


EOF

echo "backup complete!"


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29346172/viewspace-2657806/,如需轉載,請註明出處,否則將追究法律責任。

相關文章