How to use script to make mysql back up data in batches automatically
This article mainly explains "how to use a script to let mysql automatically back up data in batches". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use scripts to let mysql back up data in batches automatically".
Get the name
# cat datanames.sh
Passwd=xxxxxx
Mysql-password=$passwd mysql.txt# generates a database folder by date, which contains backup failure log I = `cat mysql.txt` nd= `date +% Y% m% d% H`dt =% Y% m% d% H% M% S`mkdir $ndfor i in $I do / usr/bin/mysqldump-pxxxxxx-- opt $I > $nd/$nm-$dt.sql 2 > $dt/error.txtdone
Set the mysqldump.sh script to join corntab to be executed once a day or once a week! Automatic backup of mysql can be realized.
1 12 *. / root/mysql_backup.sh
Thank you for your reading, the above is the content of "how to use scripts to let mysql automatically back up data in batches". After the study of this article, I believe you have a deeper understanding of how to use scripts to make mysql automatically back up data in batches. Specific use also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!