MySQL Backup and Binlog

Source: Internet
Author: User
Tags mysql backup

Modify the/etc/my.cnf below four configurations, if not, add these four.

Log-bin=mysql-bin

Binlog_format=mixed

Expire_logs_days=7

binlog-do-db=your_db

View Binlog

Mysqlbinlog--no-defaults mysql-bin.000001 | More

Recovery Binlog

./mysqlbinlog--start-date= "Yyyy-mm-dd HH:mm:ss"--stop-date= "Yyyy-mm-dd HH:mm:ss"/usr/local/mysql/data/ Mysql-bin.xxxxx/usr/local/mysql/data/mysql-bin.xxxxxx |mysql-u Root-ppassword

MySQL scheduled backup script

#!/bin/bash
#Name: bakmysql.sh
#This is a shellscript for Auto DB backup and Delete old Backup
Bakpath=/data/bakmysql
Time= ' Date +%y%m%d%h '
Mysqldump-uxxxx-pxxxx database_xxxx | gzip > $bakpath/backname$time.sql.gz
#
Find $bakpath-name "backname_*.sql.gz"-type f-mtime +7-exec rm {} \; >/dev/null 2>&1

Modify Crontab

5 3 * * * root/usr/sbin/bakmysql.sh

/etc/init.d/crond restart

MySQL Backup and Binlog

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.