MySQL backup script under Windows

Source: Internet
Author: User
Tags goto rand mysql backup

1 @echo off2 rem MySQL backup script supports full backup3REM Incremental backup requires MySQL service plus--log-Bin parameter Execution4REM Data restore Mysql-u Root-p <Backup.sql5REM =====================6 REM Global Variables7Set dump=Mysqldump.exe8Set rand=%random%9REM =====================Ten  One REM detects if the MySQL path is added to the path variable A Echo=========================================== - Echo "Data Restore command: Mysql-u root-p < Backup.sql" - Echo=========================================== the Echo. - Echodetect if MySQL is added to environment variables ... - Echo%PATH% | findstr MySQL >nul -  + if%errorlevel% EQU0Goto Dobackup - if%errorlevel% EQU1Goto Notinpath +  A :d obackup at Echo. - Echo= = Backup Option = = -set/puname=Enter user name: - Echo. - Echodo you want to back up all databases?  - Choice in if%errorlevel% EQU1Goto BACKUPALLDB - if%errorlevel% EQU2Goto BACKUPSPECIALDB to Pause + Exit -  the : Backupalldb * Echo. $ Echoback up all databasesPanax Notoginseng%dump%-u root-p--all-databases > backup_%date%_%rand%. SQL - Echo. the if%errorlevel% EQU2(Del backup_%date%_%rand%.sql &&goto Pwderror) + EchoBackup complete, backup file is backup_%date%_%rand%. SQL A Pause the Exit +  - : Backupspecialdb $ Echo. $ Echobacking up a specified database -set/p db=Enter the database name: -%dump%-u root-p%db% >"%db%_%date%_%rand%". SQL the Echo. - if%errorlevel% EQU2(Del%db%_%date%_%rand%.sql &&goto Pwderror)Wuyi EchoBackup complete, backup file is%db%_%date%_%rand%. SQL the Pause - Exit Wu  - :p Wderror About Echo. $ Echo***Wrong password!  - Echo. - Echoexit the program with any key -Pause>nul A Exit +  the : Notinpath - Echo**MySQL path is not in environment variable $ Echo. the Echodetect current working path ... the dir| findstr%dump% >nul the if%errorlevel% EQU0Goto Dobackup the if%errorlevel% EQU1Goto Notinbindir - Pause in Exit the  the : Notinbindir About Echo* * The current path does not contain%dump% the Echo. the EchoPlease add the MySQL path to the environment variable, or copy the script to the mysql/under the Bin folder the Echo. + Echoexit the program with any key -Pause>nul theExit

()

MySQL backup script under Windows

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.