#!/bin/bash
############################shell脚本说明##############xx#############
#获取数据库服务器文件到应用服务器中
#######################################################################
################具体实际步骤如下:###########
#前提:配置数据库服务器参数,配置文件路径
db_username=oracle #数据服务器登录用户账号
db_server_ip=10.192.xx.xxx #数据服务器ip
file_system_path1=/home/weblogic/files/rptExport #路径1(应用服务器存放文件路径)
file_system_path2=/home/oracle/ftp/files/rptExport #路径2 (数据库存放文件路径)
file_system_path3=/home/weblogic/files/rptExport #路径3 (shell脚本执行日志文件路径)
file_dt=$1 #文件日期,例如:20190321
exec_dt=`data "+%Y-%m-%d"` #执行日期
rm -f ${file_system_path3}/getfile_${exec_dt}.log
file_log =${file_system_path3}/getfile_${exec_dt}.log
echo "开始执行 GET DB TO WEB SERVER 跑批" >>${file_log}
echo "文件日期 :${file_dt}">>${file_log}
echo "执行日期 :${exec_dt}">>${exec_dt}
echo "WEB服务器文件存放目录:${file_system_path1}">>${file_log}
cd ${file_system_path1}
echo "sftp连接数据库服务器,执行命令:sftp ${db_server_ip}">>${file_log}
echo "sftp 连接数据库服务器获取下载文件,执行命令:get ${file_system_path2}/*${file_dt}*.gz">>${file_log}
echo "sftp连接数据库服务器下载文件,执行命令:rm ${file_system_path2}/*${file_dt}*.gz">>${file_log}
sftp ${db_username}@${db_server_ip}<> ${file_log}
echo "执行GET DB TO WEB SERVER 跑批结束">>${file_log}