Linux regular backup MySQL database

Source: Internet
Author: User

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 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. 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, make it executable # chmod + x/usr/sbin/bakmysql 4. Modify/etc/crontab # vi/etc/crontab and add 01 3 *** root/usr/sbin/ bakmysql indicates that the backup is performed at three o'clock every day. 5. Restart crond #/etc/rc. d/init. d/crond restart
Related Article

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.