RHEL5 Implementation of mysql automatic backup

Source: Internet
Author: User
Tags mysql automatic backup

RHEL5 mysql automatic backup saves you a lot of trouble, so I wrote a shell command for RHEL5 mysql automatic backup to meet the needs of lazy people. RHEL5 mysql automatic backup practices:
Linux: redhat enterprise linux 5
Mysql: 5.1.
The implementation of mysql automatic backup in RHEL5 is divided into the following steps:

1. Create a shell script file
Filename = 'date + % Y % m % d _ % H: % m'
Mysqldump -- opt database-u username-h host-ppassword | gzip>/var/mysqlbackup/export filename.gz
Then put the file in/etc/cron. daily/(directory executed every day)
/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 value: 4)
The preceding time format is m h d m d cmd ". M indicates the minute ~ 59), H indicates the hour 0 ~ 23), D Indicates Day 1 ~ 31), m represents Month 1 ~ 12), d indicates the day of a week ~ 6, 0 is Sunday ). * Indicates any. For example, 01 *** indicates the hourly rate of 01.
Edit the/etc/crontab file if it is not redhat
Gedit/etc/crontab
Gedit/etc/crontab
After completing the above steps for mysql automatic backup under RHEL5, add
01 5 *** root/opt/autobackup (above shell script file)
Run the script at 5 o'clock every day. You can also change 5 to another specified time.

2. add permissions for the script
# Chmod + x/opt/autobackup (shell script file)
# Chmod + x/opt/autobackup (shell script file)

3. Restart crontab
#/Etc/rc. d/init. d/crond restart
#/Etc/rc. d/init. d/crond restart

So far, the automatic backup of RHEL5 mysql seems OK. It is easy, but no error is reported after execution. A file named .. % Y % m % d _ % H: m.gz is found in/var/mysqlbackup/(Backup Directory). It indicates that the date file name does not take effect. After a while, I checked for a while, but I didn't know what was going on. Finally, I asked a friend, and he asked me to send the shell script. After a while. This is because filename = 'date + % Y % m % d _ % H: % M'. This "'" should be the point on the Tab key, and I use single quotes. The horse was modified. After this modification, the RHEL5 mysql automatic backup is basically implemented.

  1. Deep experience of Red Hat Enterprise RHEL5.4
  2. Step 5 of RHEL5 Squid Configuration
  3. In-depth analysis of RHEL5 Security
  4. RHEL5 NFS server maintenance procedure
  5. Three steps for configuring an NFS server in RHEL5

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.