Simple Mysql backup BAT script sharing in Windows and mysql backup bat script

Source: Internet
Author: User
Tags mysql backup

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.MysqldumpCommand to back up a specified Mysql database to a file in the format% Dbname %-yyyyMMddHHmmss. SQLOnly 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.

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.