Instance method for mysql automatic incremental backup (local backup and remote backup) bitsCN.com
1. local backup
Compile an automatic backup script:
Vim/var/lib/mysql/autobak
The content 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:
/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:
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
BitsCN.com