@echo off
color 0a
title Backup MySQL databases in separate sql files
echo.
echo.
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo º Mysql database backup in separate sql format º
echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo.
echo.
ECHO Please wait while system starts.
ping -n 3 -w 3000 0.0.0.1 > nul
echo.
echo.
echo.
echo.
:: Batch file Backup MySQL databases in separate sql files::
set dbUser=root
set dbPassword=
set port=3306
set backupDir="J:\MySQL_Database"
set mysqldump="c:\xampp\mysql\bin\mysqldump.exe"
set mysqlDataDir="c:\xampp\mysql\data"
: get date
for /F "tokens=1-3 delims=- " %%i in ('date /t') do (
set yy=%%i
set mon=%%j
set dd=%%k
)
:: get time
for /F "tokens=5-8 delims=:. " %%i in ('echo.^| time ^| find "current" ') do (
set hh=%%i
set min=%%j
)
echo dirName=%yy%%mon%%dd%_%hh%%min%
:: switch to the "data" folder
pushd %mysqlDataDir%
:: iterate over the folder structure in the "data" folder to get the databases
for /d %%f in (*) do (
if not exist %backupDir%\%dirName%\ (
mkdir %backupDir%\%dirName%
)
%mysqldump% --host="localhost" --user=%dbUser% --password=%dbPassword% --port=%port% --single-transaction --add-drop-table --databases %%f > %backupDir%\%dirName%\%%f.sql
)
popd
color 0a
title Backup MySQL databases in separate sql files
echo.
echo.
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo º Mysql database backup in separate sql format º
echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo.
echo.
ECHO Please wait while system starts.
ping -n 3 -w 3000 0.0.0.1 > nul
echo.
echo.
echo.
echo.
:: Batch file Backup MySQL databases in separate sql files::
set dbUser=root
set dbPassword=
set port=3306
set backupDir="J:\MySQL_Database"
set mysqldump="c:\xampp\mysql\bin\mysqldump.exe"
set mysqlDataDir="c:\xampp\mysql\data"
: get date
for /F "tokens=1-3 delims=- " %%i in ('date /t') do (
set yy=%%i
set mon=%%j
set dd=%%k
)
:: get time
for /F "tokens=5-8 delims=:. " %%i in ('echo.^| time ^| find "current" ') do (
set hh=%%i
set min=%%j
)
echo dirName=%yy%%mon%%dd%_%hh%%min%
:: switch to the "data" folder
pushd %mysqlDataDir%
:: iterate over the folder structure in the "data" folder to get the databases
for /d %%f in (*) do (
if not exist %backupDir%\%dirName%\ (
mkdir %backupDir%\%dirName%
)
%mysqldump% --host="localhost" --user=%dbUser% --password=%dbPassword% --port=%port% --single-transaction --add-drop-table --databases %%f > %backupDir%\%dirName%\%%f.sql
)
popd
0 comments:
Post a Comment