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