Oracle 数据库全库备份脚本

#!/bin/bash
# 按照日期为备份文件名取值
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
a=$(date +%Y%m%d)
#b=$(date -d '7 days ago' +%Y%m%d)
echo $a
#echo $b

location='/home/oracle/backup'
find $location -mtime +30 -type f |xargs rm -f 
location1='/home/oracle/log'
find $location1 -mtime +30 -type f |xargs rm -f

# 设置Oracle环境变量
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1;
export ORACLE_SID=ctms;
export PATH=/u01/app/oracle/product/11.2.0/db_1/bin:$PATH;

# 运行exp命令执行输出
exp system/oracle file=/home/oracle/backup/$a.dmp log=/home/oracle/log/Exp_$a.log full=y

 

你可能感兴趣的:(oracle,数据库,经验分享)