Use the MySQL database mysqldump tool, can realize the database backup function, if in the Linux system Configuration good crontabs, can realize the automatic backup!
#!/bin/bash
# #配置原数据库连接信息, that is, using a database machine that needs to be backed up.
Source_user=-uroot
# #如果就是在本机ip, that source_host=-h127.0.0.1
source_host=-h10.10.10.12
Source_pass=-padministrator
# #配置备份数据库的连接信息, the database machine for backup
Bak_user=-uroot
# #用于备份的数据库机器ip
bak_host=-h10.10.10.22
Bak_pass=-padministrator
# #从原数据库中导出数据库表的内容, and generate SQL files, station for database names, username and files for table names
/var/mysql/bin/mysqldump--add-drop-table--opt $SOURCE _user $SOURCE _host $SOURCE _pass Station username >/tmp/ Username.sql
/var/mysql/bin/mysqldump--add-drop-table--opt $SOURCE _user $SOURCE _host $SOURCE _pass station files >/tmp/ Files.sql
# #导入到备份的数据库中
/var/mysql/bin/mysql $BAK _user $BAK _host $BAK _pass Station </tmp/username.sql
/var/mysql/bin/mysql $BAK _user $BAK _host $BAK _pass Station </tmp/files.sql