Created
November 23, 2012 11:40
-
-
Save iAugur/4135251 to your computer and use it in GitHub Desktop.
Windows BAT files to dump MYSQL Database, purge logs and add these to Wampmanager menu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rem refer to http://perplexed.co.uk/271_batch_mysqldump_useful_development_tool.htm | |
@echo off | |
echo. | time /t | |
echo Dump local database . | |
SET /P dbname=Name of database?: | |
SET tmp_file=d:\wamp\dump\%dbname%.sql | |
echo Dumping %dbname%@LocalHost ... | |
D:\wamp\bin\mysql\mysql5.5.8\bin\mysqldump.exe -h localhost -uroot -p %dbname% > %tmp_file% | |
rem "d:\program files\winzip\wzzip" -a -m %tmp_file%.zip %tmp_file% | |
gzip -9 %tmp_file% | |
echo Completed, dumped the database %dbname% | |
echo. | time /t | |
pause | |
cls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
For /f "tokens=1-3 delims=/ " %%a in ('date /t') do (Set Datestr=%%c-%%b-%%a) | |
FOR /F "TOKENS=*" %%A IN ('TIME/T') DO SET TIME=%%A | |
SET user=<usernamehere> | |
SET pword=<passwordhere> | |
echo Purging Logs on %Datestr% >> d:/wamp/logs/mysql-log-purge.log | |
@echo off | |
echo. | time /t | |
echo Purge Binary Logs . | |
D:\wamp\bin\mysql\mysql5.5.8\bin\mysql.exe -u %user% -p %pword% -e "PURGE BINARY LOGS BEFORE '%Datestr% 00:00:01';" | |
echo D:\wamp\bin\mysql\mysql5.5.8\bin\mysql.exe -u %user% -p%pword% -e "PURGE BINARY LOGS BEFORE '%Datestr% 00:00:01';" | |
echo Completed, Purged Binary Logs | |
echo. | time /t | |
pause | |
cls | |
if %errorlevel% == 0 goto okay | |
:error | |
echo Error Purging Binary Logs %Datestr% at %Time% >> d:/wamp/logs/mysql-log-purge.log | |
eventcreate /t error /id 100 /so MYSQLPurge /l application /d "MYSqlPurge - Error" | |
goto end | |
:okay | |
rem eventcreate /t information /id 101 /so MYSQLPurge /l application /d "MYSQLPurge - Success" | |
:end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;locate the menu left section | |
[Menu.Left] | |
;WAMPMENULEFTSTART | |
Type: separator; Caption: "Powered by Alter Way" | |
Type: item; Caption: "Localhost"; Action: run; FileName: "D:\program files\Mozilla Firefox\firefox.exe"; Parameters: "http://localhost/"; Glyph: 5 | |
Type: item; Caption: "phpMyAdmin"; Action: run; FileName: "D:\program files\Mozilla Firefox\firefox.exe"; Parameters: "http://localhost/phpmyadmin/"; Glyph: 5 | |
Type: item; Caption: "Dump Local Database"; Action: run; FileName: "d:/wamp/dump.bat"; Glyph: 0 | |
Type: item; Caption: "Purge MySQL Binary Logs"; Action: run; FileName: "d:/wamp/purgelog.bat"; Glyph: 0 | |
Type: item; Caption: "www directory"; Action: shellexecute; FileName: "D:/wamp/www"; Glyph: 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment