SHARE
TWEET

mysqlbackupscript

a guest Jun 5th, 2017 21 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2.  
  3. set dbUser=root
  4. set dbPassword=password
  5.  set backupDir="C:\User\Desktop\backup\mysql"
  6. set mysqldump="C:\Program Files\MySQL\MySQL Workbench 5.2 CE\mysqldump.exe"
  7. set mysqlDataDir="C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.1\data"
  8. set zip="C:\Program Files\7-Zip\7z.exe"
  9.  
  10. :: get date
  11. for /F "tokens=2-4 delims=/ " %%i in ('date /t') do (
  12.     set mm=%%i
  13.     set dd=%%j
  14.     set yy=%%k
  15. )
  16.  
  17. :: get time
  18. for /F "tokens=5-8 delims=:. " %%i in ('echo.^| time ^| find "current" ') do (
  19.     set hh=%%i
  20.     set mm=%%j
  21. )
  22.  
  23. set dirName=%yy%%mm%%dd%_%hh%%mm%
  24.  
  25.  
  26. %mysqldump% --host="localhost" --user=%dbUser% --password=%dbPassword% --single-transaction --add-drop-table --databases %%f > %backupDir%\allizhealth-%dirName%.sql
  27.  
  28. %zip% a -tgzip %backupDir%\allizhealth-%dirName%.sql.gz %backupDir%\allizhealth-%dirName%.sql
  29.  
  30. del %backupDir%\%dirName%\%%f.sql
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top