In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the handout of the MySQL local database backup script, hoping to supplement and update some knowledge, if you have any other questions you need to know, you can continue to follow my updated article in the industry information.
This script is used for scheduled backups of local databases and scheduling tasks based on crontab
#! / bin/bash # Shell Command For Backup MySQL Database Everyday Automatically By Crontab USER=root # Database login user name PASSWORD= "1qaz2wsx" # Database login password DATABASE= "mysql" # Library to be backed up HOSTNAME= "192.168.18.5" # backup host IPWEBMASTER=test@qq.comBACKUP_DIR=/data/mysql _ back/ # backup file storage path LOGFILE=/data/data_backup.log # journal file path DATE= `date'+% Y% m% dhorse% H% M`` # date format (as file name) DUMPFILE=$DATE.sql # backup file name ARCHIVE=$DATE.sql.tgz # compressed file name OPTIONS= "- h$HOSTNAME-u$USER-p$PASSWORD $DATABASE" # mysqldump-help # determine whether the backup file storage directory exists Otherwise, create the directory if [!-d $BACKUP_DIR] Then mkdir-p "$BACKUP_DIR" fi# before starting backup Write the backup header to the diary file echo "> > $LOGFILEecho" > > $LOGFILEecho "- > > $LOGFILEecho" BACKUP DATE: "$(date +"% y-%m-%d% H:%M:%S ") > > $LOGFILEecho"-"> > $LOGFILE# to the backup directory cd $BACKUP_DIR# use the mysqldump command to back up the development database And use the formatted timestamp to name the backup file mysqldump $OPTIONS > $DUMPFILE# to determine whether the database backup is successful or not if [[$? = = 0]] Then # create an archive of backup files tar czvf $ARCHIVE $DUMPFILE > > $LOGFILE 2 > & 1 # enter the message of successful backup to the diary file echo "[$ARCHIVE] Backup Successful!" > > $LOGFILE # delete the original backup file and simply keep the compressed package of the database backup file rm-f $DUMPFILEelse echo "Database Backup Fail!" > > $LOGFILEfi# outputs a reminder that the backup process is over
Echo "Backup Process Done"
Read the above handouts on the MySQL local database backup script, hoping to give you some help in practical application. Due to the limited space in this article, it is inevitable that there will be deficiencies and need to be supplemented. If you need more professional answers, you can contact us on the official website for 24-hour pre-sales and after-sales to help you answer questions at any time.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.