Mysql Automatic Incremental Backup instance method (local backup and remote backup) _mysql

Source: Internet
Author: User
Tags flush instance method

1. Local Backup
To write an automatic backup script:
Vim/var/lib/mysql/autobak
The contents are as follows:

Copy Code code as follows:

Cd/data/home/mysqlbak
rq= ' Date +%y%m%d '
/usr/local/mysql/bin/mysqldump sqldb--flush-logs-uroot-p123456--opt > 777city_$rq.sql

Save exit.

Chmod-777/var/lib/mysql/autobak

Crontab-e
* * * */var/lib/mysql/autobak
The Autobak script is automatically executed every evening early in the morning.
/etc/init.d/crontab restart

Manually execute the script to see the effect.
./var/lib/mysql/autobak
Ls/data/home/mysqlbak

View the bottom file size
Du-sh/data/home/mysqlbak/777city11.sql

2. Remote BACKUP Database
Remote backup command:

Copy Code code as follows:

/usr/local/mysql/bin/mysqldump sqldb--flush-logs-uroot-p ' 123456 '-h ' 10.241.92.172 '--opt >/root/777city22.sql

Automatic Remote backup:
Back up the MySQL database of the ip:172 server on the ip:67 machine
To operate on a ip:67 machine:
1, write automatic backup script:
Vim/var/lib/mysql/autobak
The contents are as follows:

Copy Code code as follows:

Cd/data/home/mysqlbak
rq= ' Date +%y%m%d '
/usr/local/mysql/bin/mysqldump sqldb--flush-logs-uroot-p ' 123456 '-h ' 10.241.92.172 '--opt > 777city_$rq.sql

Save exit.

Chmod-r 777/var/lib/mysql/autobak

Crontab-e
* * * */var/lib/mysql/autobak
The Autobak script is automatically executed every evening early in the morning.
/etc/init.d/crontab restart

Manually execute the script to see the effect.
/var/lib/mysql/autobak
Ls/data/home/mysqlbak

View down file size
Du-sh/data/home/mysqlbak/777city11.sql

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.