每周一0点执行全备,其他每天执行增量备份。

定时任务如下:

0级备份脚本内容:

[oracle@zhmh-64 rman_bak]$ cat  /k8s/backup/rman_bak/rman_full_level0.sh
#!/bin/bash
#对数据库做0级备份

DAY=`date  +%Y-%m-%d`
User='sys'
Password='……'

BakDir1='/k8s/backup/rman_bak'
BakDir2='/backup/Db_Bak/Oracle/bakfile/10_236_9_14'
Host='10.236.0.96'

export ORACLE_SID=DB11G
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db_1
export PATH=$ORACLE_HOME/bin:$PATH

rman target $User/$Password << EOF   >> /k8s/backup/rman_bak/logfiles/level_0_$DAY.log
run {
    configure controlfile autobackup format for device type disk to'/k8s/backup/rman_bak/ctl_%F';
    backup incremental level 0 as compressed backupset  database format '/k8s/backup/rman_bak/full_%u.bk';
    sql 'alter system archive log current' ;
    backup archivelog all delete input format '/k8s/backup/rman_bak/arch_%u.bk';
    crosscheck backup;
    delete noprompt obsolete;
}
exit
EOF

1级备份脚本内容如下:

[oracle@zhmh-64 rman_bak]$ cat /k8s/backup/rman_bak/rman_full_level1.sh
#!/bin/bash
#对数据库做1级增量备份

DAY=`date  +%Y-%m-%d`
User='sys'
Password='……'

BakDir1='/k8s/backup/rman_bak'
BakDir2='/backup/Db_Bak/Oracle/bakfile/10_236_9_14'
Host='10.236.0.96'

export ORACLE_SID=DB11G
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db_1
export PATH=$ORACLE_HOME/bin:$PATH

rman target $User/$Password << EOF   >> /k8s/backup/rman_bak/logfiles/level_1_$DAY.log
run {
    configure controlfile autobackup format for device type disk to'/k8s/backup/rman_bak/ctl_%F';
    backup incremental level 1 as compressed backupset  database format '/k8s/backup/rman_bak/full_%u.bk';
    sql 'alter system archive log current' ;
    backup archivelog all delete input format '/k8s/backup/rman_bak/arch_%u.bk';
    crosscheck backup;
    delete noprompt obsolete;
}
exit
EOF

#将备份远程拷贝到10.236.0.96上
cd $BakDir1

find ./  -type f -name "ctl_*" -exec scp {} oracle@$Host:$BakDir2 \;
rm ./ctl_*

find ./  -type f -name "full_*" -exec scp {} oracle@$Host:$BakDir2 \;
rm ./full_*

find ./  -type f -name "arch_*" -exec scp {} oracle@$Host:$BakDir2 \;
rm ./arch_*

 

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐