This is my simple script used to do a mysqldump on Windows server and then associate it with Windows Scheduler task.
Mysqldump syntax, there are three general ways to invoke mysqldump:
I found few other script here and there and i combine it in one script here:
Mysqldump syntax, there are three general ways to invoke mysqldump:
shell> mysqldump [options] db_name [tables] shell> mysqldump [options] --databases db_name1 [db_name2 db_name3...] shell> mysqldump [options] --all-databases
I found few other script here and there and i combine it in one script here:
REM [at] echo offHere is the sample output on Windows command :
for /f "tokens=1" %%i in ('date /t') do set DATE_DOW=%%i
for /f "tokens=2" %%i in ('date /t') do set DATE_DAY=%%i
for /f %%i in ('echo %date_day:/=-%') do set DATE_DAY=%%i
for /f %%i in ('time /t') do set DATE_TIME=%%i
for /f %%i in ('echo %date_time::=-%') do set DATE_TIME=%%i
"C:\Program Files\MySQL\MySQL Server 4.1\bin\mysqldump" -u root -p207007 --all-databases> "C:\mySQL_Backup\%DATE_DAY%_%DATE_TIME%_db.sql"
"C:\Program Files\7-Zip\7z.exe" a -t7z "C:\mySQL_Backup\%DATE_DAY%_%DATE_TIME%_db.7z" "C:\mySQL_Backup\%DATE_DAY%_%DATE_TIME%_db.sql"
del "C:\mySQL_Backup\%DATE_DAY%_%DATE_TIME%_db.sql"
C:\>REM [at] echo offThe compressing will show you the percentage complete, and once compressing complete it will delete the original sql dump file.
C:\>for /F "tokens=1" %i in ('date /t') do set DATE_DOW=%i
C:\>set DATE_DOW=Wed
C:\>for /F "tokens=2" %i in ('date /t') do set DATE_DAY=%i
C:\>set DATE_DAY=10/05/2011
C:\>for /F %i in ('echo 10-05-2011') do set DATE_DAY=%i
C:\>set DATE_DAY =10-05-2011
C:\>for /F %i in ('time /t') do set DATE_TIME=%i
C:\>set DATE_TIME=04:48
C:\>for /F %i in ('echo 04-48') do set DATE_TIME=%i
C:\>set DATE_TIME=04-48
C:\>"C:\Program Files\MySQL\MySQL Server 4.1\bin\mysqldump" -u root -p207007 --all-databases 1>"C:\mySQL_Backup\10-05-2011_04-48_db.sql"
C:\>"C:\Program Files\7-Zip\7z.exe" a -t7z "C:\mySQL_Backup\10-05-2011_04-48_db.7z" "C:\mySQL_Backup\10-05-2011_04-48_db.sql"
7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Scanning
Creating archive C:\mySQL_Backup\10-05-2011_04-48_db.7z
Compressing 10-05-2011_04-48_db.sql 56%
0 comments:
Post a Comment