MySQL database backup operation in Linux

Source: Internet
Author: User
Tags mysql backup

1. Create a new SH script (you can first build a txt text and then change to SH file).

The code is as follows:

#!/bin/bash#set up MySQL backup directoryfolder=/**/**CD$folder Day=`Date+%y%m%d ' RM-rf$daymkdir $dayCD$day#Database ServerIp=ip Address#Database Port numberhost= Database Port#User nameUser=Root#Passwordpassword=password for database root#the database to be backed updb=Database name#number of days to retain dataDays=7mysqldump-H$ip-P$host-U$user-P$password $db> Genereview.Sqlzip Backup. Sql.zip Backup.SQLRM Backup.SQLCD.. Day=`Date-D "$daysDays Ago "+%y%m%d ' RM-rf$day

2.linux Scheduled tasks are managed by Crond, insert scripts, run regularly

[[Email protected]MySQL]#crontab-e* * * * */opt/mysqlbakup.SH//script path~                                                                                                                 ~                                                                                                                 ~                                                                                                                 ~                                                                                                                 ~                                                                                                                                                                 ~ --INSERT--

3. Start the Crond service, this service is normally boot-up

MySQL] # Service Crond Restart Redirecting To/bin/systemctl restart Crond. Service[[email protected]MySQL # crontab-l//View timed Task Information * * */opt/mysqlbakup.sh

MySQL database backup operation in Linux

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.