Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of using crontab to back up Mysql database regularly in Linux system

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report