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 RQ = 'date + % Y % m % d' MySQL
DuMP -- 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. Each user may be different./mysqldata/indicates the directory where the backup files are saved, this individual can also do it according to their own requirements. 3. Modify file attributes to make them executable #
Chmod+ X/usr/sbin/bakmysql 4. Modify/etc/crontab # vi/etc/crontab and add 01 3 * root/usr/sbin/bakmysql to execute the command at three o'clock every day. backup 5. Restart crond #/etc/rc. d/init. d/crond restart is complete. In this way, you can view the file mysql20040619.tar.gz on/mysqldata every day. You can download the file directly.
Reprinted please noteArticleSource: http://www.linuxso.com/a/linuxbiancheng/450.html