Backup MySQL database tasks regularly every day

Source: Internet
Author: User

1, backup MySQL data at 0 points per day;

2, in order to save space, delete more than 3 months of all backup data;

3, delete more than 7 days of backup data, retain 3 months of 10th number 20th number 30th of the backup data;

#创建shell文件vim backup_mysql.shmysqldump-uroot-p123456--all-databases  >/data/dbdata/mysqlbak/' Date +%Y%m%d ' . sqlfind/data/dbdata/mysqlbak/-mtime +7-name ' *[1-9].sql '-exec rm-rf {} \;find/data/dbdata/mysqlbak/-mtime +92-nam E ' *.sql '-exec rm-rf {} \; #创建定时任务crontab –e0 0 * *  /data/dbdata/backup_mysql.sh

Note: Backing up data
Mysqldump--extended-insert=false/true
Difference: The former is an insert statement-by-record way | and relatively low efficiency, backup file is relatively large
The latter is compressed for insert records | Relatively efficient and efficient

Backup MySQL database tasks regularly every day

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.