English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Preface
As everyone knows, data is a relatively important data that needs to be backed up frequently, and it is麻烦 to do it manually each time. Let's take a look at how to set up daily automatic backup of mysql in CentOS system through this article.
The steps are as follows
Create backup folder:
mkdir mysql_data_bak
Create script file:
touch autobackupmysql.sh
Open the file
vi autobackupmysql.sh
Add the following content to the script:
filename=`date +%Y%m%d` /usr/bin/mysqldump -uroot -proot boss >>/home/mysql_data_bak/$filename.sql
Check if crond is installed, if not, install it first
yum -y install vixie-cron yum -y install crontabs
Start service: service crond start
Add automatic startup in CentOS system: chkconfig --level 345 crond on
crontab -e
Add content:00 03 * * * source /root/autobackupmysql.sh
Every morning3Run this file to back up the database
service crond restart
Alright, that's it.
Summary
That's all for this article. I hope the content of this article can bring you some help in learning or working. If you have any questions, you can leave a message for communication. Thank you for your support of the Yelling tutorial.