Created
May 18, 2012 11:39
-
-
Save koma5/2724822 to your computer and use it in GitHub Desktop.
automated mysql dumps on windows - dumps all dbs which user sees
This file contains 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
set MYSQLUSER=username | |
set MYSQLPASS=password | |
set BATCHFILE=C:\Temp\auto_built_sql_dump.bat | |
set DUMPPATH=Z:\ | |
set DRIVE=Z: | |
net use %DRIVE% \\somehost\some\networkdrive /user:domain\user password | |
rem building time stamp | |
set tmp_time=%time:~-11,2%.%time:~-8,2%.%time:~-5,2% | |
set tmp_time=%tmp_time: =0% | |
set mydate=%date:~-4,4%.%date:~-7,2%.%date:~-10,2%-%tmp_time% | |
echo @echo off > %BATCHFILE% | |
echo cd %DUMPPATH% >> %BATCHFILE% | |
echo %DRIVE% >> %BATCHFILE% | |
mysql -u%MYSQLUSER% -p%MYSQLPASS% -AN -e"SELECT CONCAT('mysqldump -u%MYSQLUSER% -p%MYSQLPASS% --routines --triggers ',schema_name,' > ',schema_name,'-dump-%mydate%.sql') FROM information_schema.schemata WHERE schema_name NOT IN ('information_schema','performance_schema','mysql')" >> %BATCHFILE% | |
type %BATCHFILE% | |
%BATCHFILE% | |
del %BATCHFILE% | |
net use Z: /d /yes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment