本地备份数据库
#!/bin/bash
export ORACLE_BASE=/software/app/oracle
export ORACLE_HOME=/software/app/oracle/product/11.2.0/dbhome_1

export PATH=P A T H : PATH:PATH:HOME/bin:$ORACLE_HOME/bin

#export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib

YESTERDAY=date -d yesterday +%Y%m%d

#/home/oracle/app/product/11.2.0/db_1/bin/expdp system/ZAQ1xsw2@orcl DIRECTORY=backup DUMPFILE=full_Y E S T E R D A Y . d m p l o g = YESTERDAY.dmp log=YESTERDAY.dmplog=YESTERDAY.log FULL=y

expdp system/LW_SYS_2017@localhost/ATS50 DIRECTORY=DMPDATA DUMPFILE=full_KaTeX parse error: Expected group after '_' at position 23: …AY.dmp log=full_̲YESTERDAY.log FULL=y

#删除7天前备份数据
find /software/app/backup -name ‘full_*’ -type f -mtime +7 -exec rm {} ;

find /software/app/backup -name ‘*.log’ -type f -mtime +7 -exec rm {} ;

传数据到异地
需要安装sftp和lftp

#!/bin/bash
#SFTP配置信息
#IP
IP=10.196.12.2
#端口
PORT=22
#用户名
USER=oracle
#密码
PASSWORD=*********
#待上传文件根目录
CLIENTDIR=/software/app/backup
#SFTP目录
SEVERDIR=/software/app/backup
#待上传文件名
date=date -d yesterday +%Y%m%d
FILE=full_${date}*
#FILE=test.log

lftp -u U S E R , {USER},USER,{PASSWORD} sftp://I P : {IP}:IP:{PORT} <<EOF
cd $SEVERDIR
lcd $CLIENTDIR
mput $FILE
by
EOF