How to make a full-pants backup of MySQL under Windows

Source: Internet
Author: User
Tags goto rar

Usually back up a database, directly trousers backup , a more complete point will be required to do a scheduled trousers backup . However, many times because the pants instances are too many, this can lead to a very time-consuming backup, so sometimes the entire database application needs to be backed up. So how do you do a scheduled backup of your entire application under Windows?

1. Batch backup script ( note the variables inside the script )

@echo Off &setlocal enableextensions:: Date set TODAY=%Date:~0,4%%Date:~5,2%%Date:~8,2%:: Source program is located in directory set DATAPATH=e:\bak\data\*:: Backup directory set Bakpath=E:\webInfobackup:: Backup name prefix set bakname=mg3mydata::+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++::+++++++++ This directory is a backup directory, it will be deleted after compression, it is important to note when modifying ++++++++Set Srcpath=%bakpath%\%bakname%%today%::+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Call :D Ate2day%Date:~0,Ten%Sdaysset/A sdays-=7Call :D ay2date%sdays%difdateEchoStart bauckup MySQL%Date:~0,4%-%Date:~5,2%-%Date:~8,2% % Time:~0,2%:% Time:~3,2%:% Time:~6,2% >>log.log:: Shut down MySQL service net stop mysql:: Copy data directory xcopy%datapath%%srcpath%\/E/y:: Open mysql service net start MySQLEchoBauckup MySQL finish%Date:~0,4%-%Date:~5,2%-%Date:~8,2% % Time:~0,2%:% Time:~3,2%:% Time:~6,2% >>log.log:: Compress the database file and delete"C:\Program Files\winrar\winrar.exe"A-r-ep2-ibck-inul-DF-T%srcpath%.rar%srcpath%EchoCompress MySQL data finish%Date:~0,4%-%Date:~5,2%-%Date:~8,2% % Time:~0,2%:% Time:~3,2%:% Time:~6,2% >>log.log::++++++++++++++++++ Deleting a directory ++++++++++++++Rd/Q/S%srcpath% ::++++++++++++++++++ Deleting a directory ++++++++++++++:: Delete backup files N days ago for/R%bakpath%%%finch(%bakname%*.rar) Do if "%%~TF"LEQ"%difdate%"Del"%%f"goto:eof exit:date2daysetlocal enableextensions for/F"tokens=1-3 delims=/-,"%%ainch('echo/%1') Do(Set yy=%%a & Set Mm=%%b & SetDD=%%c) Set/ADD= -%DD%%% -, mm= -%mm%%% -Set/A z= --mm,z/= A, y=yy+4800-z,m=mm+ A*z-3, j=153*m+2Set/A j=j/5+DD+y*365+y/4-y/ -+y/ --2472633endlocal&set%2=%j%&goto:eof:D ay2datesetlocal enableextensions Set/A i=%1, a=i+2472632, b=4*a+3, b/=146097, c=-b*146097, c/=4, c+=a set/A d=4*c+3, d/=1461, e=-1461*d,e/=4, e+=c,m=5*e+2, m/=153,DD=153*m+2,DD/=5Set/ADD=-DD+e+1, mm=-m/Ten, mm*= A, mm+=m+3, yy=b* -+d-4800+m/Ten (if%mm% LSSTenSet mm=0%mm%) & (if%DD% LSSTenSetDD=0%DD%) endlocal&set%2=%yy%%mm%%DD%&goto:eof

2. Create a task plan

Do not know can GG, not in detail in this article.

How to make a full-pants backup of MySQL 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.