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.
- Deep experience of Red Hat Enterprise RHEL5.4
- Step 5 of RHEL5 Squid Configuration
- In-depth analysis of RHEL5 Security
- RHEL5 NFS server maintenance procedure
- Three steps for configuring an NFS server in RHEL5