linux下rman自动备份,Linux 下的rman自动备份

1. 创建基本目录

$ mkdir rmanbackup

然后在rmanbackup下面创建以下目录

$ mkdir scripts

$ mkdir archivelog

$ mkdir control

$ mkdir databak

$ mkdir log

2.创建脚本

$ vi rman_bak.sh

脚本内容:

#### script start ####

#!/bin/bash

#set env

export ORACLE_BASE=/opt/oracle

export ORACLE_HOME=/opt/oracle/product/11.2.0/

export ORACLE_SID=orcl

export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

export PATH=$ORACLE_HOME/bin:$PATH

DATE=`date +%w`

DATE_2=`date +%Y%m%d`

BACKUP_PATH=/u01/rmanbackup

TARGET_SID=orcl

BIN=$ORACLE_HOME/bin

echo "-----------------------------start-----------------------------";date

$BIN/rman log $BACKUP_PATH/log/$TARGET_SID.$DATE_2.log <

connect target /;

crosscheck archivelog all;

crosscheck backup;

delete noprompt expired archivelog all;

delete noprompt obsolete;

delete expired copy;

delete noprompt expired backup;

run{

allocate channel c1 type disk ;

backup as compressed  backupset database format '$BACKUP_PATH/databak/full_%d_%T_%t_%s' tag='full';

backup as compressed  backupset archivelog all delete all input skip inaccessible format '$BACKUP_PATH/archivelog/arch_%d_%t';

backup current controlfile format '$BACKUP_PATH/control/control_%d_%t';

release channel c1 ;

}

EOF

echo "------------------------------end------------------------------";date

#### script start ####

3.赋执行权限

$  chmod +x rman_bak.sh

4.做数据库全备

$ ./ rman_bak.sh

5.增加计划任务

$crontab -e

00 01 * * * . /opt/app/oracle/rman_bak/scripts/rman_bak.sh

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值