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

How to realize automatic backup of mysql in RHEL5

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article will explain in detail how to achieve mysql automatic backup in RHEL5. The content of the article is of high quality, so Xiaobian shares it with you as a reference. I hope you have a certain understanding of relevant knowledge after reading this article.

1. Creating shell script files

filename=`date +%Y%m%d_%H:%M`

mysqldump --opt database -u username -h host -ppassword | gzip > /var/mysqlbackup/$filename.gz

Then put the file in/etc/cron.daily/(daily execution directory)

/etc/cron.hourly/ (hourly)

/etc/cron.monthly/ (monthly)

/etc/cron.weekly/ (weekly)

Then edit the/etc/crontab file and change the time parameter before/etc/cron.daily (default is 4 o'clock).

The preceding time format is "M H D m d cmd." where M represents minutes (0 - 59), H represents hours (0 - 23), D represents days (1 - 31), m represents months (1 - 12), and d represents days of the week (0 - 6, 0 being Sunday). * It means anything. For example, 01 * * * indicates that 01 minutes per hour is executed

If not redhat, edit the/etc/crontab file

gedit /etc/crontab

gedit /etc/crontab

mysql automatic backup under RHEL5 After completing the above steps, add in ***

01 5 * * * root /opt/autobackup(shell script file above)

Run the script at 5:00 a day, or modify 5 to another specified time

2. Add permissions to scripts

# chmod +x /opt/autobackup

# chmod +x /opt/autobackup

3. Restart crontab

# /etc/rc.d/init.d/crond restart

# /etc/rc.d/init.d/crond restart

How to achieve mysql automatic backup in RHEL5 is shared here. I hope the above content can be of some help to everyone and learn more knowledge. If you think the article is good, you can share it so that more people can see it.

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

Servers

Wechat

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

12
Report