Instance method for mysql automatic Incremental Backup (local backup and remote backup)

Source: Internet
Author: User

1. Local backup
Compile an automatic backup script:
Vim/var/lib/mysql/autobak
The content is as follows:

Copy codeThe Code is 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 and exit.

Chmod-777/var/lib/mysql/autobak

Crontab-e
00 00 ***/var/lib/mysql/autobak
The autobak script is automatically executed every morning.
/Etc/init. d/crontab restart

Manually execute the script to check the effect.
./Var/lib/mysql/autobak
Ls/data/home/mysqlbak

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

2. Remote database backup
Remote backup command:

Copy codeThe Code is as follows:/usr/local/mysql/bin/mysqldump sqldb -- flush-logs-uroot-p '000000'-H' 10. 241.92.172 '-- opt>/root/777city22. SQL

Automatic Remote Backup:
Back up the mysql database of an ip: 172 server on a machine with ip: 67
Perform operations on machines with ip Address: 67:
1. Compile an automatic backup script:
Vim/var/lib/mysql/autobak
The content is as follows:

Copy codeThe Code is as follows: cd/data/home/mysqlbak
Rq = 'date + % Y % m % d'
/Usr/local/mysql/bin/mysqldump sqldb -- flush-logs-uroot-p '000000'-H' 10. 241.92.172 '-- opt> 777city _ $ rq. SQL

Save and exit.

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

Crontab-e
00 00 ***/var/lib/mysql/autobak
The autobak script is automatically executed every morning.
/Etc/init. d/crontab restart

Manually execute the script to check the effect.
/Var/lib/mysql/autobak
Ls/data/home/mysqlbak

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

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.