linux环境下oracle备份脚本

#!/bin/sh
source /home/oracle/.bash_profile
$ORACLE_HOME/bin/rman <<EOF
connect target /
run{
allocate channel 'd1' type disk;
allocate channel 'd2' type disk;
allocate channel 'd3' type disk;
allocate channel 'd4' type disk;
backup full tag 'dbfull' format '/archive/backup/full%u_%p_%c' database;
sql 'alter system archive log current';
backup format '/archive/backup/%T_arch_%s_%p' archivelog all delete input;
release channel d1;
release channel d2;
release channel d3;
release channel d4;
}
list backup;
exit;
EOF
echo "-------------------------end------------------------------";date


crontab的格式:
minutes|hours|day of month|month|day of week|
下面是在CRONTAB里面的语句
03 23 * * 0 /home/oracle/backupscript/b_fullbackup.sh
00 02 01 * *
上面是一个全备份。

下面是一个一零级备份的脚本:
source /home/oracle/.bash_profile
$ORACLE_HOME/bin/rman <<EOF
connect target /
run{
allocate channel 'd1' type disk;
allocate channel 'd2' type disk;
allocate channel 'd3' type disk;
allocate channel 'd4' type disk;
backup incremental level 0 cumulative tag 'db0' format '/home/oracle/backup/db0%u_%s_%p' database;
sql 'alter system archive log current';
backup filesperset 4 archivelog all delete input;
delete noprompt obsolete;
release channel d1;
release channel d2;
release channel d3;
release channel d4;
}
list backup;
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
exit;
EOF
echo "-------------------------end------------------------------";date

下面是一个一级备份脚本:

source /home/oracle/.bash_profile
$ORACLE_HOME/bin/rman <<EOF
connect target /
run{
allocate channel 'd1' type disk;
allocate channel 'd2' type disk;
allocate channel 'd3' type disk;
allocate channel 'd4' type disk;
backup incremental level 1 cumulative tag 'db1' format '/home/oracle/backup/db1%u_%s_%p' database;
sql 'alter system archive log current';
backup filesperset 4 archivelog all delete input;
delete noprompt obsolete;
release channel d1;
release channel d2;
release channel d3;
release channel d4;
}
list backup;
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
exit;
EOF
echo "-------------------------end------------------------------";date




ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1;
export ORACLE_HOME
ORACLE_SID=orcl1;
export ORACLE_SID
rq=" data+'%m%d' "
/u01/app/oracle/product/10.2.0/db_1/bin/exp system/oracle file=/bak/backup/exp$rq.dmp full=y

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值