关闭

备份

标签: datedatabaseuploadfilecompressionserver
580人阅读 评论(0) 收藏 举报

 @echo off
rem +----------------------------------------------------
rem + Backup Database file for EAPT every day
rem + Writed by Liudefang 26/05/2006
rem +----------------------------------------------------

set RARFile=EAPT.RAR
set DBDir=d:/backup
set FTPDestPath=EAPTTEST
set FTPUser=sysbackup
set FTPPwd=Ea.com

set RARFile_PATH=%DBDIR%/%RARFile%
date /t | findstr 星期日
if %Errorlevel% EQU 0 goto 1
date /t | findstr 星期一
if %Errorlevel% EQU 0 goto 2
date /t | findstr 星期二
if %Errorlevel% EQU 0 goto 3
date /t | findstr 星期三
if %Errorlevel% EQU 0 goto 4
date /t | findstr 星期四
if %Errorlevel% EQU 0 goto 5
date /t | findstr 星期五
if %Errorlevel% EQU 0 goto 6
date /t | findstr 星期六
if %Errorlevel% EQU 0 goto 7
goto end

:1
set WhichDir=%DBDir%/week1
set whichDay=week1
goto end
:2
set WhichDir=%DBDir%/week2
set whichDay=week2
goto end
:3
set WhichDir=%DBDir%/week3
set whichDay=week3
goto end
:4
set WhichDir=%DBDir%/week4
set whichDay=week4
goto end
:5
set WhichDir=%DBDir%/week5
set whichDay=week5
goto end
:6
set WhichDir=%DBDir%/week6
set whichDay=week6
goto end
:7
set WhichDir=%DBDir%/week7
set whichDay=Week7
:end

rem +-------------------------------
rem + Build ftp script file
rem +-------------------------------
echo user %FTPUser% %FTPPwd% >ftp.txt
echo bin >>ftp.txt
echo cd %FTPDestPath%/%whichDay% >>ftp.txt
echo put %RARFile% >>ftp.txt
echo bye >>ftp.txt


rem +---------------------------------
rem + EXP EAPT Data
rem +---------------------------------
echo %date% %time%: ************Export EAPT database starting ...************* [ OK ]>>backup.log
exp EA0711/EA0711@ORCL file=%WhichDir%/EAPTbak.dmp log=d:/backup/EAPT.log
if not %Errorlevel% EQU 0  goto Err2
echo %date% %time%: Exp EAPT database  ...... [ OK ]>>backup.log


rem +---------------------------------
rem + Compress Database_backup Directory
rem +---------------------------------
call compress_rar %whichDir% %RARFile% backup.log EAPT数据库备分

 


rem +---------------------------------------------------
rem + Upload to backup server
rem +---------------------------------------------------

echo %date% %time%: Starting Upload database file to server ......>>backup.log
ftp -n -i -s:ftp.txt 172.29.13.253
if NOT %Errorlevel% EQU 0 goto Err1
echo %date% %time%: Upload database file to server ...... [ OK ]>>backup.log
goto Exit
:Err1
echo %date% %time%: Upload database file to server ...... [ Failure ]>>backup.log
:Err2
echo %date% %time%: Exp database EAPT ...... [ Failure ]>>backup.log
goto Exit

del %RARFile_PATH%
del ftp.txt

 

 

 

 

 

 

 

@echo off
rem +-----------------------------
rem + Backup Database files Script
rem + Date:     2006-05-23
rem + Description:
rem + -IBCK Background archiving
rem + -EP2 Expand paths to full
rem + -O+ Overwrite existing files
rem + -y Assume Yes on all queries
rem + u Update files within an archive
rem + -m5 Best compression method(most compressive but also most slow)
rem + -ilog[] Log errors to file
rem + @file Listfiles are plain text files contained names of files to process 
rem + %1 Destination RAR filename
rem + %2 Source filepath or file
rem + %3 Logfile name
rem + %4 Banner information
rem +-----------------------------

rem set DestPath=F:/eternal.backup/EAPTdb.rar
rem set SourcePath=F:/eternal.backup/baklist.txt
if "%1"=="" goto USAGE
if "%2"=="" goto USAGE
if "%3"=="" goto USAGE
if "%4"=="" goto USAGE
echo ****************************************************************************>>%3
echo *  %DATE% %4 >>%3
echo ****************************************************************************>>%3

if not exist "%ProgramFiles%/winrar/WinRAR.exe" (
 echo %date% %time%: WinRar is not exist in system. Pls check ......    [ Failure ]>> %3
 
) else ( 
 path=%ProgramFiles%/winrar;%PATH% 
 echo %date% %time%: Compress start   .......   [ OK ] >>%3
   rem WinRAR.exe u -y -O+ -EP2 -IBCK -ilog%3 -m5 %2 %1
   WinRAR.exe u -y -O+ -EP2 -IBCK -m5 %2 %1
   if %errorlevel%==0 goto SUCCESS
   if %errorlevel%==1 echo %date% %time%: ***Not fatally Error*** ......    [ Failure ]>>%3   
   if %errorlevel%==2 echo %date% %time%: ***Fatally Error*** ......    [ Failure ]>>%3
   if %errorlevel%==3 echo %date% %time%: ***CRC Error***   ......    [ Failure ]>>%3
   if %errorlevel%==5 echo %date% %time%: ***Write disk error*** ......    [ Failure ]>>%3
   if %errorlevel%==6 echo %date% %time%: ***Open file error*** ......    [ Failure ]>>%3
   if %errorlevel%==7 echo %date% %time%: ***Command line option error*** ......    [ Failure ]>>%3
   if %errorlevel%==8 echo %date% %time%: ***Not enough memory*** ......    [ Failure ]>>%3
   if %errorlevel%==9 echo %date% %time%: ***Create file error*** ......    [ Failure ]>>%3   
   if %errorlevel%==255 echo %date% %time%: ***User interrupt operation*** ......    [ Failure ]>>%3   
   goto end
   :SUCCESS
 echo %date% %time%: Compress Success             .......  [ OK ]>> %3
)
goto END
:USAGE
echo.
echo Usage: Compress files and directory tress.
echo        %0 [Source] [Destination] [LogName] [Banner]
echo.
echo        Source  Source filepath or files
echo        Destionation Destination RAR filename
echo        LogName  Logfile name
echo        Banner  Banner information
echo.
echo eg: %0 c:/temp/*.* c:/temp.rar c:/test.log.txt It's_only_for_test.
echo.
:END

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:106277次
    • 积分:1955
    • 等级:
    • 排名:千里之外
    • 原创:84篇
    • 转载:0篇
    • 译文:0篇
    • 评论:25条
    文章分类
    最新评论