oracle for linux 備份指令碼
1.oracle賬號的contab中加入以下,包含dp備份,rman備份和備份刪除
########### delete archivelog and database backup #############################
00 07 * * * sh /exp/backup/delete.sh > /exp/backup/delete.log
########### rman backup ##############################################
00 23 * * 0 sh /exp/backup/incr0.sh > /exp/backup/incr0.log
30 23 * * 1,2,3,4,5,6 sh /exp/backup/incr1.sh > /exp/backup/incr1.log
30 11 * * * sh /exp/backup/export.sh > /exp/backup/export.log 2>&1
2.以下檔案內容
###########/exp/backup/export.sh
#!/bin/sh
#function:using data pump backup database
export ORACLE_SID=$SID #$SID 為oracle sid
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
export PATH=.:$ORACLE_HOME/bin:$PATH:.
action_time=`date +%Y_%m_%d`
del_time=`date -d "10 day ago" +%Y_%m_%d`
echo action time:$action_time
filename=$SID_$action_time.dmp #$SID 為oracle sid
logname=$SID_$action_time.log #$SID 為oracle sid
#filedir=/u10/dump
expdp system/password content=all full=y directory=dump dumpfile=$filename logfile=$logname
cd /u10/dump
mv *.gz *.log /u09/hisdp
tar -czvf $SID_$action_time.tar.gz $filename $logname #$SID 為oracle sid
rm $filename
chmod 755 $SID_$action_time.tar.gz $logname #$SID 為oracle sid
#del dump data
path="/u09/hisdp"
echo "delete dump data 10 day ago"
rm -rf $path/$SID_$del_time.tar.gz #$SID 為oracle sid
rm -rf $path/$SID_$del_time.log #$SID 為oracle sid
echo "delete 10 dump data OK!"
###############/exp/backup/incr0.sh
# RMAN level o backup
#!/bin/sh
export ORACLE_SID=$SID #$SID 為oracle sid
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
export PATH=.:$ORACLE_HOME/bin:$PATH:.
rman target / << EOF
run
{
allocate channel d1 type disk maxpiecesize 4000m;
allocate channel d2 type disk maxpiecesize 4000m;
allocate channel d3 type disk maxpiecesize 4000m;
allocate channel d4 type disk maxpiecesize 4000m;
backup current controlfile format '/u09/orabackup/$SID/full/control/full_1_%d_%s_%p_%c.ctl';
backup incremental level 0 database format '/u09/orabackup/$SID/full/full_db_%d_%s_%p_%c.dbfbk'
plus archivelog delete input format '/u09/orabackup/$SID/full/full_log_%d_%s_%p_%c.dbfbk';
backup current controlfile format '/u09/orabackup/$SID/full/control/full_2_%d_%s_%p_%c.ctl';
release channel d4;
release channel d3;
release channel d2;
release channel d1;
}
exit
EOF
#################/exp/backup/incr1.sh
# RMAN level 1 backup
#!/bin/sh
export ORACLE_SID=$SID #$SID 為oracle sid
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
export PATH=.:$ORACLE_HOME/bin:$PATH:.
rman target / << EOF
run
{
allocate channel d1 type disk maxpiecesize 4000m;
allocate channel d2 type disk maxpiecesize 4000m;
allocate channel d3 type disk maxpiecesize 4000m;
allocate channel d4 type disk maxpiecesize 4000m;
backup current controlfile format '/u09/orabackup/$SID/control/%d_%s_%p_%c.ctl'; #$SID 為oracle sid
sql 'alter system switch logfile';
backup incremental level 1 database FORMAT '/u09/orabackup/$SID/db_%d_%s_%p_%c.dbfbk' #$SID 為oracle sid
plus archivelog delete input FORMAT '/u09/orabackup/$SID/log_%d_%s_%p_%c.dbfbk'; #$SID 為oracle sid
release channel d4;
release channel d3;
release channel d2;
release channel d1;
}
exit
EOF
##################/exp/backup/delete.sh
#!/bin/bash
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
export PATH=.:$ORACLE_HOME/bin:PATH:.
#delete archivelog and database backup on primary database completed before 7 days
rman target sys/password@$SID << EOF #$SID 為oracle sid
delete force noprompt backup completed before 'sysdate-7';
delete force noprompt archivelog all completed before 'sysdate-7';
exit;
EOF
#delete archivelog on standby database completed before 7 days
rman target sys/password@$SB_SID << EOF #$SB_SID 為standby oracle sid
delete force noprompt archivelog all completed before 'sysdate-7';
exit;
EOF
########### delete archivelog and database backup #############################
00 07 * * * sh /exp/backup/delete.sh > /exp/backup/delete.log
########### rman backup ##############################################
00 23 * * 0 sh /exp/backup/incr0.sh > /exp/backup/incr0.log
30 23 * * 1,2,3,4,5,6 sh /exp/backup/incr1.sh > /exp/backup/incr1.log
30 11 * * * sh /exp/backup/export.sh > /exp/backup/export.log 2>&1
2.以下檔案內容
###########/exp/backup/export.sh
#!/bin/sh
#function:using data pump backup database
export ORACLE_SID=$SID #$SID 為oracle sid
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
export PATH=.:$ORACLE_HOME/bin:$PATH:.
action_time=`date +%Y_%m_%d`
del_time=`date -d "10 day ago" +%Y_%m_%d`
echo action time:$action_time
filename=$SID_$action_time.dmp #$SID 為oracle sid
logname=$SID_$action_time.log #$SID 為oracle sid
#filedir=/u10/dump
expdp system/password content=all full=y directory=dump dumpfile=$filename logfile=$logname
cd /u10/dump
mv *.gz *.log /u09/hisdp
tar -czvf $SID_$action_time.tar.gz $filename $logname #$SID 為oracle sid
rm $filename
chmod 755 $SID_$action_time.tar.gz $logname #$SID 為oracle sid
#del dump data
path="/u09/hisdp"
echo "delete dump data 10 day ago"
rm -rf $path/$SID_$del_time.tar.gz #$SID 為oracle sid
rm -rf $path/$SID_$del_time.log #$SID 為oracle sid
echo "delete 10 dump data OK!"
###############/exp/backup/incr0.sh
# RMAN level o backup
#!/bin/sh
export ORACLE_SID=$SID #$SID 為oracle sid
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
export PATH=.:$ORACLE_HOME/bin:$PATH:.
rman target / << EOF
run
{
allocate channel d1 type disk maxpiecesize 4000m;
allocate channel d2 type disk maxpiecesize 4000m;
allocate channel d3 type disk maxpiecesize 4000m;
allocate channel d4 type disk maxpiecesize 4000m;
backup current controlfile format '/u09/orabackup/$SID/full/control/full_1_%d_%s_%p_%c.ctl';
backup incremental level 0 database format '/u09/orabackup/$SID/full/full_db_%d_%s_%p_%c.dbfbk'
plus archivelog delete input format '/u09/orabackup/$SID/full/full_log_%d_%s_%p_%c.dbfbk';
backup current controlfile format '/u09/orabackup/$SID/full/control/full_2_%d_%s_%p_%c.ctl';
release channel d4;
release channel d3;
release channel d2;
release channel d1;
}
exit
EOF
#################/exp/backup/incr1.sh
# RMAN level 1 backup
#!/bin/sh
export ORACLE_SID=$SID #$SID 為oracle sid
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
export PATH=.:$ORACLE_HOME/bin:$PATH:.
rman target / << EOF
run
{
allocate channel d1 type disk maxpiecesize 4000m;
allocate channel d2 type disk maxpiecesize 4000m;
allocate channel d3 type disk maxpiecesize 4000m;
allocate channel d4 type disk maxpiecesize 4000m;
backup current controlfile format '/u09/orabackup/$SID/control/%d_%s_%p_%c.ctl'; #$SID 為oracle sid
sql 'alter system switch logfile';
backup incremental level 1 database FORMAT '/u09/orabackup/$SID/db_%d_%s_%p_%c.dbfbk' #$SID 為oracle sid
plus archivelog delete input FORMAT '/u09/orabackup/$SID/log_%d_%s_%p_%c.dbfbk'; #$SID 為oracle sid
release channel d4;
release channel d3;
release channel d2;
release channel d1;
}
exit
EOF
##################/exp/backup/delete.sh
#!/bin/bash
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
export PATH=.:$ORACLE_HOME/bin:PATH:.
#delete archivelog and database backup on primary database completed before 7 days
rman target sys/password@$SID << EOF #$SID 為oracle sid
delete force noprompt backup completed before 'sysdate-7';
delete force noprompt archivelog all completed before 'sysdate-7';
exit;
EOF
#delete archivelog on standby database completed before 7 days
rman target sys/password@$SB_SID << EOF #$SB_SID 為standby oracle sid
delete force noprompt archivelog all completed before 'sysdate-7';
exit;
EOF
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28539951/viewspace-1296700/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- linux下oracle熱備份指令碼LinuxOracle指令碼
- ORACLE備份指令碼Oracle指令碼
- oracle 備份指令碼Oracle指令碼
- ORACLE日常備份指令碼Oracle指令碼
- Oracle 集中備份指令碼Oracle指令碼
- oracle RMAN備份指令碼Oracle指令碼
- oracle_備份指令碼Oracle指令碼
- Oracle冷備份(一致備份)指令碼Oracle指令碼
- [Oracle] rman備份指令碼(2)Oracle指令碼
- Oracle邏輯備份指令碼Oracle指令碼
- oracle rman備份指令碼收集Oracle指令碼
- Oracle物理冷備份指令碼Oracle指令碼
- 分享Oracle Rman的備份指令碼Oracle指令碼
- ORACLE常用定時備份指令碼Oracle指令碼
- oracle自動冷備份指令碼Oracle指令碼
- oracle rman 定時備份指令碼Oracle指令碼
- ORACLE自動備份shell指令碼Oracle指令碼
- Oracle用指令碼執行備份Oracle指令碼
- [Oracle] rman備份的指令碼(1)Oracle指令碼
- ORACLE RMAN備份的指令碼配置Oracle指令碼
- Oracle物理熱備份指令碼(ZT)Oracle指令碼
- oracle備份指令碼_user_passwordOracle指令碼
- 備份指令碼指令碼
- 備份&恢復系列之三:在linux中對oracle用rman指令碼備份!LinuxOracle指令碼
- linux 下RMAN備份shell指令碼Linux指令碼
- oracle11g Rman 備份指令碼Oracle指令碼
- windows 下的Oracle 冷備份指令碼WindowsOracle指令碼
- oracle 自動冷備份指令碼(轉)Oracle指令碼
- rman備份和增量備份指令碼指令碼
- mysqldump 備份指令碼MySql指令碼
- rman 備份指令碼指令碼
- mysqldump備份指令碼MySql指令碼
- innobackupex備份指令碼指令碼
- SQLServer備份指令碼SQLServer指令碼
- SQL 備份指令碼SQL指令碼
- Mongodb 備份指令碼MongoDB指令碼
- rman備份指令碼指令碼
- mysql備份指令碼MySql指令碼