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