一、实现本地自动备份数据库很简单:
1.以root身份登陆
2.计划任务(每天的3:30自动执行 /usr/bin/mysqlbackup)
crontab
0 3:30 * * * /usr/bin/mysqlbackup
3.写一个自动备份数据库脚本
vi /usr/bin/mysqlbackup
#!/bin/bash
mv /home/.../db_bak5.tgz /home/.../db_bak6.tgz
mv /home/.../db_bak4.tgz /home/.../db_bak5.tgz
mv /home/.../db_bak3.tgz /home/.../db_bak4.tgz
mv /home/.../db_bak2.tgz /home/.../db_bak3.tgz
mv /home/.../db_bak1.tgz /home/.../db_bak2.tgz
rm -rf /home/.../db_bak.txt
/usr/bin/mysqldump -uroot -ppassword dbname
/home/.../db_b...[ 查看全文 ]