원문 : http://www.ischo.net -- 조인상 //시스템 엔지니어

+++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

시나리오 : 원격지의 FTP서버에 있는 데이터를 내 windows PC로 백업해 온다.

 

환경 : Linux FTP서버

          내 windows PC : windows 7

           원격지 파일명  20140513.tar.gz

 

 

 

다음 스크립트를 작성하여 윈도우 작업스케줄러에 등록해준다.

 

rem ####################################################################
rem #    ENVIRONMENT SETTING                                           #
rem ####################################################################

set SERVER=서버IP

set USER=FTP유저명
set PASSWORD=FTP패스워드

 

set LOCAL_HOME=D:\backup
set LOCAL_BACKUP_DEST=%LOCAL_HOME%\daily
set FTP_COMMAND=%LOCAL_HOME%\script\backup_to_mypc.ftp

 

set REMOTE_DIR=원격지서버의 디렉토리명
set FILE1=%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%.tar.gz
rem ####################################################################
rem #    END OF ENVIRONMENT SETTING                                    #
rem ####################################################################

 

 

rem ####################################################################
rem #    RUN FTP                                                       #
rem ####################################################################

echo open %SERVER% > %FTP_COMMAND%
echo user %USER% %PASSWORD% >> %FTP_COMMAND%
echo lcd %LOCAL_BACKUP_DEST% >> %FTP_COMMAND%
echo cd %REMOTE_DIR% >> %FTP_COMMAND%
echo binary >> %FTP_COMMAND%
echo prompt >> %FTP_COMMAND%
echo quote pasv >> %FTP_COMMAND%
echo get %FILE1% >> %FTP_COMMAND%
echo bye >> %FTP_COMMAND%


cd %LOCAL_BACKUP_DEST%
ftp -n -d -s:%FTP_COMMAND%

del /q %FTP_COMMAND%

 

 

 

(*.118.235.233)