日期:2014-05-16 浏览次数:20780 次
@echo off set day=%date:~8,2% set month=%date:~5,2% set year=%date:~0,4% set yyyymmdd=%year%%month%%day% set dataDir=F:/data/ set dataDisk=F: set datafiles=*.dat set sshDir=C:/Program Files/OpenSSH/home/Administrator/work set sshDisk=C: set stockMarket=ShenZhen set tarPackagefile=%stockMarket%-%yyyymmdd%.tar set dataInfoListfile=%stockMarket%HostDataInfoList-%yyyymmdd%.txt set gzipPackagefile=%tarPackagefile%.gz set md5file=%stockMarket%Checkmd5-%yyyymmdd%.windows echo %packagefile% echo %dataInfoListfile% echo %gzipPackagefile% echo %md5file% @echo 检查目录是否存在 if exist "%dataDir%" (@echo %dataDir% 目录存在) else (@echo %dataDir% 目录不存在) if not exist "%dataDir%" goto quit if exist "%sshDir%" (@echo %sshDir% 目录存在) else (@echo %sshDir% 目录不存在) if not exist "%sshDir%" goto quit @echo 进入当前目录:cd %dataDir% cd\ %dataDisk% cd %dataDir% if exist %tarPackagefile% (@echo 删除文件:"%gtarPackagefile%") if exist %tarPackagefile% del %tarPackagefile% if exist %gzipPackagefile% (@echo 删除文件:"%gzipPackagefile%") if exist %gzipPackagefile% del %gzipPackagefile% @echo 进入当前目录:cd %sshDir% cd\ %sshDisk% cd %sshDir% if exist %dataInfoListfile% (@echo 删除文件:"%dataInfoListfile%") if exist %dataInfoListfile% del %dataInfoListfile% if exist %md5file% (@echo*删除文件:"%md5file%") if exist %md5file% del %md5file% if exist %gzipPackagefile% (@echo 删除文件:"%gzipPackagefile%") if exist %gzipPackagefile% del %gzipPackagefile% @echo 进入当前目录:cd %dataDir% cd\ %dataDisk% cd %dataDir% @echo 获取目录%dataDir%下文件名和大小并存入文件 "%sshDir%/%dataInfoListfile%" for /f "delims=" %%a in ('dir /b/a-d/oN *.*') do echo %%a %%~za >> "%sshDir%/%dataInfoListfile%" @echo 进入当前目录:cd %sshDir% cd\ %dataDisk% cd %dataDir% @echo 归档目录%dataDir%下原始文件为 "%tarPackagefile%" ...... tar -cvf %tarPackagefile% %datafiles% @echo; @echo 正在压缩 "%tarPackagefile%" 为: %gzipPackagefile% ...... if exist %tarPackagefile% (gzip "%tarPackagefile%") @echo 正在移动文件%gzipPackagefile% ,从%dataDir%到%sshDir% if exist %gzipPackagefile% (move "%gzipPackagefile%" "%sshDir%") @echo 进入当前目录:cd %sshDir% @echo 检查文件是否创建成功...... cd\ %sshDisk% cd %sshDir% if exist "%sshDir%/%dataInfoListfile%" (@echo 成功创建 "%dataInfoListfile%" ) else (@echo 创建 "%dataInfoListfile%" 失败) if exist "%sshDir%/%gzipPackagefile%" (@echo 成功创建 "%gzipPackagefile%") else (@echo 创建 "%gzipPackagefile%" 失败) if exist "%sshDir%/%gzipPackagefile%" (md5sum -b %gzipPackagefile% >> %md5file%) else (@echo 创建 "%md5file%" 失败) if exist "%sshDir%/%md5file%" (@echo 成功创建 "%md5file%") else (@echo 创建 "%md5file%" 失败) @echo; @echo; @echo; :quit exit
#主机IP hostIp='192.168.1.254' #主机端口 port='22' #网络传输带宽 例如:1000/8=125kB/s 8000/8=1MB/S 10000/8=1.25MB/s networkBandwidth=10000 #主机用户登录名 user='admin' #主机本地存放的数据目录 hostLocalDir='/home/admin/work' #远程目录 hostdir=$user'@'$hostIp':'$hostLocalDir #本地存储目录 localdir='/home/cyp/Desktop' #定义日志输出类型 0:OK message Type,1:Error Message type,2:Label Message Type okType=0 errorType=1 sysType=2 #系统提示信息 shellStart='**********************************ShellStart**********************************' shellEnd='**********************************ShellEnd**********************************' #日志打印函数 printlogMsg() { #体统时间 yyyymmddhhmmss=$(date +"%Y-%m-%d %H:%M:%S") echo ''$1','$2'',$yyyymmddhhmmss >> $localdir/$resultLogfile echo ''$1','$2'',$yyyymmddhhmmss >> $localdir/$historyResultLogfile } #获取系统时间,格式为YYYYMMDD yyyymmdd=$(date +%Y%m%d) #定义原始文件压缩文件名 stockMarket='ShenZhen' #原始文件压缩包文件名 packagefile=$stockMarket-$yyyymmdd'.tar.gz' #原始文件压缩包md5验证windows编码格式文件 md5WindowsFormatfile=$stockMarket'Checkmd5-'$yyyymmdd'.windows' #原始文件压缩包md5验证unix编码格式文件 md5UnixFormatfile=$stockMarket'Checkmd5-'$yyyymmdd'.unix' #原始文件压缩包md5验证unix编码格式临时文件 tempCheckMd5Resultfile=$stockMarket'TempCheckmd5-'$yyyymmdd'.txt' #存储原始文件压缩包信息列表临时文件 tempDataInfoListfile