Windows Server regularly backs up database scripts

Source: Internet
Author: User

Save the following file as a. bat script and add a scheduled task to the scheduled task to run the script.
The backup directory in the script, the database directory and the compressed file directory should be modified by yourself.
@echo Offrem The current path to the BACKUP database directory CD D:\wamp\www\databasesrem new backup directory by time: In the format of the year \ Month \ Day MD%Date:~0,4%\%Date:~5,2%\%Date:~8,2%REM Set TEMP variable: Backup directory set backuppath=d:\wamp\www\databases\%Date:~0,4%\%Date:~5,2%\%Date:~8,2%rem Current path switch to database directory CD D:\WAMP\BIN\MYSQL\MYSQL5.5.20\binrem running the BACKUP DATABASE command mysqldump-uroot-proot Shanghai >%backuppath%\shanghai.sqlrem The following two commands are: current directory switch to the compressor directory CD C:\Program files\winrarc:rem compress the SQL script just backed up winrar a%backuppath%\shanghai.rar%backuppath%\shanghai.sqlrem The following two commands are: The current directory is cut back to the database backup directory D:CD%backuppath%REM Delete database backup files, keep only compressed files del shanghai.sql

Windows Server regularly backs up database scripts

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.