Posts tagged mysql
MySQL Dump using Command Line
May 16th
Simple Batch File taking database name as argument:
Ref manual: http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
dump.bat [fixed for time 0-30-32.sql was breaking the file name.]
:: Date [yy:mm:dd]
For /f "tokens=1-3 delims=/. " %%a in ('date /t') do (
set tws_date_yy=%%c
set tws_date_mm=%%b
set tws_date_dd=%%a
)
:: Time [hh:mm]
For /f "tokens=1-8 delims=/:." %%a in ('time /t') do (
set tws_time_hh=%%a
set tws_time_mm=%%b
)
:: Time [ss]
For /f "tokens=1-3 delims=/:," %%a in ("%TIME%") do (
set tws_time_ss=%%c
)
:: DateTime format
set tws_form=%tws_date_yy%-%tws_date_mm%-%tws_date_dd%_%tws_time_hh%-%tws_time_mm%-%tws_time_ss%
mysqldump.exe --skip-compact --skip-extended-insert --skip-quote-names --skip-add-locks --comments --routines --triggers --events -h 127.0.0.1 -P 3306 -u root %1 -p > %1_%tws_form%.sql
execute
dump.bat dbname
output (file): dbname-YYYY-MM-DD_HH-MM-SS.sql
modify given options for your need


LinkedIn
Twitter
Skype