Backing up MySQL db with Coldfusion

I want to make a backup task in Coldfusion (possibly in a scheduled task) that will support the structure and data in the MySql database.

The hosting server that I use always blocks the use of cfexecute for security purposes, so I can not use mysqldump.

eg.

<cfexecute name="c:\program files\mysql\mysql server 4.1\bin\mysqldump"
 arguments="--user=xxx --password=yyy dharma" 
 outputfile="#expandPath("./ao.sql")#" timeout="30"/>

(From Raymond Camden)

Are there any other options available to me?

+4
source share
1 answer

, , , . . script .bat

@ECHO OFF


@REM Set dir variables. Use ~1 format in win2k

SET basedir={directory where zip files will be put}
SET workdir={Working directory}
SET mysqldir=c:\PROGRA~1\mysql\mysqls~1.5\bin
SET gzipdir=c:\PROGRA~2\GnuWin32\bin
SET mysqlpassword={db password}
SET mysqluser={db user}
SET host={host IP or domain name}
for /f "tokens=1-4 delims=/ " %%a in ('date/t') do ( 
set mm=%%a
set dd=%%b
set yy=%%c
)

ECHO Check connection
PING -n 1 %host%|find "Reply from " >NUL
IF NOT ERRORLEVEL 1 goto :SUCCESS
IF ERRORLEVEL 1 goto :END

:SUCCESS
ECHO Connection found, run backup

@REM Change to mysqldir
CD %mysqldir%

@REM dump database. This is all one line
mysqldump -h %host% -u %mysqluser% -p%mysqlpassword% --databases {space delimited list of databases to backup >%workdir%\backup.sql

@REM Change to workdir  
CD %workdir%

@REM Zip up database
%gzipdir%\gzip.exe backup.sql

@REM Move to random file name
MOVE backup.sql.gz %basedir%\%yy%_%mm%_%dd%_backup.gz

@REM Change back to base dir
CD %basedir%

:END
ECHO No connection, do not run

Windows, . , , .

, gzip.

. .

+7

All Articles