Activities

October 2009
M T W T F S S
« Aug   Nov »
 1234
567891011
12131415161718
19202122232425
262728293031  

Windows ftp backup scheduler

This simple ftp script will help you upload files to remote ftp location and able to use it as scheduler in windows.

Suppose we have remote windows 2003 server

For doing this we need 2 component.

1. Ftp.exe ( copy the ftp.exe from windows xp which support upload more than 2 GB on a single file but ftp command on windows 2003 not).
2. ftp account configuration file ( ftp.trf)
3. a batch file (ftp_bk.bat)
4. Gnu zip ( http://www.gnu.org/software/gzip/)

Here we go,

This scripts uses to dump a test MySQL database and uploaded it to a ftp location

create a file on notepad and save it as “ftp_bk.bat” with the following contents,

REM starting batch file
for /f “tokens=1,2,3,4 delims=/ ” %%a in (“%date%”) do set wday=%%a&set month=%%b&set day=%%c&set year=%%d
Set today=ftpupload-%day%-%month%-%year%
echo %today%

REM Creating temporary directory to dump the sql file
set temp_dir=D:backup
mysqldump –all-database %temp_dir%%today%.sql -uroot -ppwd
REM Compressing script to zip file
zip -q %temp_dir%%today%.zip %temp_dir%%today%.sql
REM uploading zipped database dump using the ftp details from ftp.trf
ftp -n -s:ftp.trf
removing
REM emptying temp direcoty
del /q %temp_dir%*.*

2. Here is ftp configuration file details.

open 208.109.188.16
user ftpusername
ftppassword
prompt
lcd c:backup
cd backup
bin
mput *.zip
by

This script will upload zipped database file to backup folder on the remote ftp location.

Now we have everyting ready to have a trail run. Pls note that allways keep the batch file and ftp config. file on the same directory.

good luck.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>