The system crontab is used to regularly execute Backup files and save the backup results by date to achieve the purpose of backup.
1. Create the path to save the backup file/mysqldata
# Mkdir/mysqldata
2. Create the/usr/sbin/bakmysql file.
# Vi/usr/sbin/bakmysql
Input
RQ = 'date + % Y % m % d'
Tar zcvf/mysqldata/mysql1_rq.tar.gz/var/lib/MySQL
Or write it
RQ = 'date + % Y % m % d'
Mysqldump -- all-databases-u root-P password>/mysqldata/MySQL $ RQ. SQL
/Var/lib/MySQL is the directory of your database files. Some users are/usr/local/MySQL/data.
/Mysqldata/indicates the directory where the backup file is saved. This can be done according to your requirements.
3. Modify file attributes to make them executable.
# Chmod + x/usr/sbin/bakmysql
4. Modify/etc/crontab
# Vi/etc/crontab
Add
01 3 *** root/usr/sbin/bakmysql
Indicates that a backup is performed at three o'clock every day.
5. Restart crond.
#/Etc/rc. d/init. d/crond restart
Complete.
In this way, you can see such files in/mysqldata every day.
Mysql20040619.tar.gz
You can download it directly.