Get the App
SLTechnology News&Howtos  ›  Database  › 

How to use script to make mysql back up data in batches automatically

Shulou Source: shulou.com Published: 2022-05-31 18:00:47 10月03日 Update

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!

Tags: Data backup script database learning content name that is ideas situations files folders text articles logs dates more knowledge knowledge points articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno macOS NVidia Redmi vpn