What is the method of using crontab to back up Mysql database regularly in Linux system
Linux system using crontab regular backup Mysql database method is how, I believe many inexperienced people are helpless, for this reason this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
The system crontab is used to execute backup files regularly, and the backup results are saved according to the date to achieve the purpose of backup.
1. Create a path to save backup files/mysqldata#mkdir /mysqldata2. Create a file/usr/sbin/bakmysql #vi /usr/sbin/bakmysql
input
rq= date +%Y%m%dtar zcvf /mysqldata/mysql$rq.tar.gz /var/lib/mysql
Or write
rq= date +%Y%m%dmysqldump -all-databases -u root -p cipher> /mysqldata/mysql$rq.sql
/var/lib/mysql is the directory of your database files, some users are/usr/local/mysql/data, everyone may be different
/mysqldata/indicates the directory where backup files are saved, which everyone can do according to their own requirements.
3. Modify the file attributes so that it can execute # chmod +x /usr/sbin/bakmysql4. Modify/etc/crontab#vi /etc/crontab
Add below
01 3 * * * root /usr/sbin/bakmysql
means backup is performed at 3 o'clock every day
The requested URL/etc/rc.d/was not found on this server.
Done.
So every day you can see this file in/mysqldata
mysql20040619.tar.gz
You can download it directly.
After reading the above, do you know how to use crontab to backup Mysql database regularly in Linux system? If you still want to learn more skills or want to know more related content, welcome to pay attention to the industry information channel, thank you for reading!