Created
October 3, 2015 19:57
-
-
Save claytonaalves/48ff1488741abb1c1372 to your computer and use it in GitHub Desktop.
MySQL backup batch script
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 This batch script requires command line verson of 7zip to work. | |
| REM | |
| REM Command to create windows task schedule: | |
| REM | |
| REM schtasks /create ^ | |
| REM /tn "MySQL Backup" ^ | |
| REM /tr C:\script_folder\backup.bat ^ | |
| REM /sc DAILY ^ | |
| REM /sd 03/10/2015 ^ | |
| REM /st 13:45 | |
| @echo off | |
| SET host=192.168.1.1 | |
| SET user=mysqluser | |
| SET password=mysqlpassword | |
| SET backup=mysqldump -h %host% -u %user% -p%password% --default-character-set=utf8 --hex-blob | |
| SET filename=Backup_%date:/=-%.zip | |
| cd C:\script_folder\ | |
| %backup% database_name > backup_file.sql | |
| 7za a %filename% *.sql > nul | |
| del /q *.sql | |
| move *.zip backup_folder > nul |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment