Simple Mysql backup BAT script sharing in Windows and mysql backup bat script
Preface
This document describes a simple BAT script for Mysql backup in Windows.Mysqldump
Command to back up a specified Mysql database to a file in the format% Dbname %-yyyyMMddHHmmss. SQL
Only the backups of the last 60 days are retained. If you want to regularly execute the task, add a task plan in Windows. For details, refer to this article.
The sample code is as follows:
@ Echo offset hour = % time :~ 0, 2% if "% time :~ 0% % "=" "set hour = time :~ 1, 1% set now = % Date :~ 0, 4% % Date :~ 5, 2% % Date :~ 8, 2% % hour % Time :~ 3,2% % Time :~ 6, 2% echo % now % set host = xxx. xxx. xxx. xxxset port = 3306 set user = rootset pass = rootset dbname = datanameset backupfile = E: \ backup \ db \ % dbname %-% now %. sqlE: \ Backups \ mysql-5.7.13-winx64 \ bin \ mysqldump-h % host %-P % port %-u % user %-p % pass %-c -- add-drop-table % dbname %> % backupfile % echo delete files before 60 daysforfiles/p "E: \ backup \ db "/m *. SQL/d-60/c "cmd/c del @ file/f"
Summary
The above is all the content of this article. I hope the content of this article will help you in your study or work. If you have any questions, please leave a message, thank you for your support.